无法使用\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}