16

I would like to draw the set of points in the complex plane that satisfies $|z-1+i| <= 3$ using LaTeX (with TikZ, or some related system). I would want to fill this circle with say dashed lines, or something of the sort, so that it's not "completely" filled. I would also want the axis labeled. I have no idea on how to do this properly, unfortunately. Could anyone tell me how, or supply me with some reference? Would be perfect.

20

You can do it as follows. See the comments in the code for explanations:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \begin{scope}[thick,font=\scriptsize]
    % Axes:
    % Are simply drawn using line with the `->` option to make them arrows:
    % The main labels of the axes can be places using `node`s:
    \draw [->] (-5,0) -- (5,0) node [above left]  {$\Re\{z\}$};
    \draw [->] (0,-5) -- (0,5) node [below right] {$\Im\{z\}$};

    % Axes labels:
    % Are drawn using small lines and labeled with `node`s. The placement can be set using options
    \iffalse% Single
    % If you only want a single label per axis side:
    \draw (1,-3pt) -- (1,3pt)   node [above] {$1$};
    \draw (-1,-3pt) -- (-1,3pt) node [above] {$-1$};
    \draw (-3pt,1) -- (3pt,1)   node [right] {$i$};
    \draw (-3pt,-1) -- (3pt,-1) node [right] {$-i$};
    \else% Multiple
    % If you want labels at every unit step:
    \foreach \n in {-4,...,-1,1,2,...,4}{%
        \draw (\n,-3pt) -- (\n,3pt)   node [above] {$\n$};
        \draw (-3pt,\n) -- (3pt,\n)   node [right] {$\n i$};
    }
    \fi
    \end{scope}
    % The circle is drawn with `(x,y) circle (radius)`
    % You can draw the outer border and fill the inner area differently.
    % Here I use gray, semitransparent filling to not cover the axes below the circle
    \path [draw=none,fill=gray,semitransparent] (+1,-1) circle (3);
    % Place the equation into the circle:
    \node [below right,gray] at (+1,-1) {$|z-1+i| \leq 3$};
\end{tikzpicture}
\end{document}

Result

There is also the patterns library which allows you to fill the circle with several different patterns, but personally I would prefer semi-transparent fillings.

  • @Jasper: That's correct. I added that labels at the very end and didn't thought about that. – Martin Scharrer May 15 '11 at 18:00
  • 1
    @MartinScharrer: Very nice! I added your example to the TikZ gallery: A circle in the complex plane Is this ok for you? – Stefan Kottwitz Jan 6 '12 at 23:00
  • How does one use options to set the axis tick labels, as in how do I choose which labeling scheme to use? – SeSodesa Sep 8 '18 at 11:50
16

You could use the PGFPlots package for this. By using the option disabledatascaling, you can draw objects using \node and \draw and the like with the axis coordinates:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    xmin=-4.5,
    xmax=4.5,
    ymin=-4.5,
    ymax=4.5,
    axis equal,
    axis lines=middle,
    xlabel=Re($z$),
    ylabel=Im($z$),
    disabledatascaling]

\fill [opacity=0.3] (1,-1) circle [radius=3];
\end{axis}
\end{tikzpicture}
\end{document}

circle in complex plane

  • @Jasper: Good point! – Jake May 15 '11 at 18:02
  • +1 for disbledatascaling cool way to use tikz commands with pgfplots – SPV May 15 '18 at 17:38
8
\documentclass{article}
\usepackage{pst-plot}
\begin{document}

\begin{pspicture}(-5,-5)(5,5)
\psaxes{->}(0,0)(-4,-4)(4,4)[Re($z$),-90][Im($z$),180]
\pscircle*[linecolor=red,opacity=0.3](1,-1){3}
\end{pspicture}

\end{document}

enter image description here

  • 1
    true, but I defined the equation as y=Re(x)+Im(x) ... :-)) – user2478 May 15 '11 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.