请参阅下面的椭圆代码,我想为椭圆的第一象限添加阴影,请指导我该怎么做。提前致谢。
\begin{tikzpicture}
\draw (-5,0)--(5,0) (4.1,0)node{A} (0,3)--(0,-3)(0,2.2)node{B};
\draw(0,0)node{O}circle[x radius = 4 cm , y radius = 2 cm];
\end{tikzpicture}
答案1
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[red] (4,0) arc[x radius = 4 cm , y radius = 2 cm,start angle=0,end
angle=90] |- cycle;
\draw (-5,0)--(5,0) (4.1,0)node{A} (0,3)--(0,-3)(0,2.2)node{B};
\draw(0,0)node{O}circle[x radius = 4 cm , y radius = 2 cm];
\end{tikzpicture}
\end{document}
如果您确实想将节点放在轴的顶部,请考虑使用contour
。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{contour}
\begin{document}
\begin{tikzpicture}
\fill[red] (4,0) arc[x radius = 4 cm , y radius = 2 cm,start angle=0,end
angle=90] |- cycle;
\draw (-5,0)--(5,0) (4,0)node[right]{\contour{white}{$A$}}
(0,3)--(0,-3) (0,2)node[above]{\contour{white}{$B$}};
\draw(0,0)node{\contour{white}{$O$}}
circle[x radius = 4 cm , y radius = 2 cm];
\end{tikzpicture}
\end{document}