![如何在 Tikz 中填充半环?](https://linux22.com/image/407223/%E5%A6%82%E4%BD%95%E5%9C%A8%20Tikz%20%E4%B8%AD%E5%A1%AB%E5%85%85%E5%8D%8A%E7%8E%AF%EF%BC%9F.png)
我用以下 tikz 代码绘制了一个半环:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% The axes
\draw[help lines,->] (-4,0) -- (4,0) coordinate (xaxis);
\draw[help lines,->] (0,-1) -- (0,4) coordinate (yaxis);
%The path
\path[draw,line width=0.8pt] (2.7182818284590452353602874713527,0) node[below] {$e$} arc (0:180:2.7182818284590452353602874713527) node[below] {$-e$} -- (-1,0) node[below]{$-1$} arc (180:0:1) node[below]{$1$} -- (2.7182818284590452353602874713527,0);
% The labels
\node[below] at (xaxis) {$x$};
\node[left] at (yaxis) {$y$};
\node[below left] {$0$};
\end{tikzpicture}
\end{document}
现在我想用某种颜色填充这个半环,比如蓝色,但我不知道该怎么做。你能帮帮我吗?
答案1
这是一个使用极坐标的好机会:(angle:radius)
。
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% The semiring
\draw[fill=blue!20,thick]
(0:1)node[below=2.5ex,anchor=base]{$1$} --
(0:3)node[below=2.5ex,anchor=base]{$\epsilon$} arc
(0:180:3cm) --
(180:1) arc
(180:0:1cm)
;
% The axes
\draw[->] (-4,0) -- (4,0)node[below]{$x$};
\draw[->] (0,-1) -- (0,4)node[left]{$y$} ;
% The label
\node[below left=2.5ex,anchor=base] at (0,0){$0$};
\end{tikzpicture}
\end{document}