如何在 Tikz 中填充半环?

如何在 Tikz 中填充半环?

我用以下 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}

相关内容