
無法使用\clip
命令突出顯示橢圓和直線的交點部分,請對此提供協助。這裡我要填寫ABCD區域,請指導謝謝
\documentclass{article}
\usepackage{tikz,pgfplots}
%\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\pgfdeclarelayer{bg} % declare background
\pgfsetlayers{bg,main} % order of layers (main = standard layer)
\pgfplotsset{compat=1.13}
\usepackage{amsmath}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\draw (0,-2)--(0,3);
\draw (-4,0)--(5,0);
\draw (0,0)node(o){O} (0,1)[left]node(c){C} (0,-1)node(d){D};
\draw(0,0)circle[x radius = 3 cm , y radius = 1 cm]; % DRAW ELLIPSE
\draw (1,-1)[below]node(a){A}--(1,1)[above]node(b){B};
\clip(0,0)circle[x radius = 3 cm , y radius = 1 cm];
\fill[black] (0cm,0cm) rectangle (4cm,6cm);
\draw (0,0)node(o){O} (0,1)[left]node(c){C};
\end{tikzpicture}
\end{document}
答案1
你想要這樣的東西嗎?您沒有得到任何可見結果的原因是您填充了零寬度的矩形。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,-2)--(0,3);
\draw (-4,0)--(5,0);
\draw(0,0)circle[x radius = 3 cm , y radius = 1 cm]; % DRAW ELLIPSE
\draw (1,-1)[below]node(a){A}--(1,1)[above]node(b){B};
\clip(0,0)circle[x radius = 3 cm , y radius = 1 cm];
\draw[blue,thick] (a) -- (b);
\end{tikzpicture}
\end{document}
至於您更新的問題,您將點a
、b
和定義c
為d
節點,它們是擴充物件。這就是為什麼連接這些點的路徑存在間隙,導致fill
失敗。為了避免這種情況,請使用coordinate
帶有標籤的類型節點。
\documentclass{article}
\usepackage{tikz}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}
\begin{document}
\begin{tikzpicture}
\draw (0,-2) -- (0,3);
\draw (-4,0) -- (5,0);
\draw (0,0)circle[x radius = 3 cm , y radius = 1 cm]; % DRAW ELLIPSE
\draw (1,-1)coordinate[label=below:$A$](a)
-- (1,1)coordinate[label=above:$B$](b);
\draw (0,0)coordinate[label=below left:$O$](o)
(0,1)coordinate[label=left:$C$](c)
(0,-1)coordinate[label=below:$D$](d);
\begin{pgfonlayer}{bg}
\clip (0,0) circle[x radius = 3 cm , y radius = 1 cm];
\fill[blue] (a) -- (b) -- (c) -- (d) -- cycle;
\end{pgfonlayer}
\end{tikzpicture}
\end{document}