2

I have drawn a halfring with the following tikz code:

\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}

Now I want to fill this halfring with some colour, say blue, but I do not know how I could do it. Could you please help me?

2
  • 1
    You can draw a single closed curve and fill it. With polar coordinates, it is easy: \draw[fill=blue] (0:1)node[below]{$1$} -- (0:3)node[below]{$\epsilon$} arc (0:180:3cm) -- (180:1) arc (180:0:1cm);
    – Sigur
    Commented Jan 29, 2020 at 21:34
  • Thanks for your help, this worked.
    – 3nondatur
    Commented Jan 29, 2020 at 21:57

1 Answer 1

4

This is a good opportunity to use polar coordinates: (angle:radius).

enter image description here

\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}
2
  • Again thanks a lot.
    – 3nondatur
    Commented Jan 29, 2020 at 22:02
  • 1
    a bit shorter \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture} \draw[fill=blue!20,thick] (0:1)node[below]{$1$}-- (0:3)node[below]{$\epsilon$} arc(0:180:3)--(180:1) arc(180:0:1); \draw[->] (-4,0)--(4,0)node[below]{$x$}; \draw[->] (0,-1)--(0,4)node[left]{$y$} ; \node[below left] at (0,0){$0$}; \end{tikzpicture} \end{document}
    – Black Mild
    Commented Jan 30, 2020 at 2:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .