5

I'd like to create a graph like this in LaTeX:

enter image description here

I already tried with pst-all but I've no clue how to do this. So I hope you can help me. PD: I already searched about this in this page and I didn't find anything that could help me.

2
  • Could you show us this "already tried with pst-all" method?
    – Werner
    May 20, 2015 at 21:52
  • I read this page (thelazymathematician.com/p/pstricks-examples.html) and I tried to do that graph, but I don't know how to plot a vector (only points) and I had some issues with the axis: I don't know how to make the axis look like the image. Where else could I read about this?
    – francolino
    May 20, 2015 at 21:56

5 Answers 5

6

You can try using pgfplots and tikz. It's quite easy.

The figure might look something like this.

\documentclass{article}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [<->] (0,4) node[left]{$ \text{Im} (z) $} -- (0,0) -- (4,0) node[below]{$ \text{Re} (z) $};
\draw [->] (0,0) -- (3,3)node[above right]{$ z+\beta $};
\draw [->] (0,0) -- (1,2)node[left]{$ \beta $};
\draw [dashed] (0,0) -- (2,1)node[right]{$ z $};
\draw [->] (2,1) -- (3,3);
\draw [dashed] (1,2) -- (3,3);
\end{tikzpicture}
\end{document}

output

2
  • 3
    Nice, but in this example you don't actually need pgfplots.
    – Pier Paolo
    May 20, 2015 at 22:10
  • I'd say it would be better to create two \nodes or \coordinates for z and \beta and then use ($ (z) + (b) $) to automatically compute the third point. In this way if you want to change the orientation of the segments you can simply change z and b and the other point is computed automatically.
    – Bakuriu
    May 21, 2015 at 7:01
5

Here's a slightly different approach using TikZ that uses the vector arithmetic of the calc library to place some of the arrows.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\begin{document}

\begin{tikzpicture}[>=Stealth]

  \coordinate (Q) at (0,0);
  \coordinate (RE) at (4,0);
  \coordinate (IM) at (0,4);

  %% axes
  \draw[arrows=->] (Q) -- (RE) node [pos=1,below] {$Re(z)$};
  \draw[arrows=->] (Q) -- (IM) node [pos=1,left]  {$Im(z)$};

  %% beta vector
  \coordinate (beta) at (1.5,2);
  \draw[arrows=->] (Q) -- (beta) node [pos=1,left] {$\beta$};

  %% z vector
  \coordinate (z) at (2.5,1); 
  \draw[dashed] (Q) -- (z) node[pos=1,right] {$z$};

  %% betaSUMz
  \coordinate (betaSUMz) at ($(beta)+($(z)-(Q)$)$);
  \draw[arrows=->] (Q) -- (betaSUMz);

  %% missing sides
  \draw[dashed] (beta) -- (betaSUMz);
  \draw         (z)    -- (betaSUMz);
\end{tikzpicture}

\end{document}

enter image description here

5

With \pstricks (can be compiled under conditions with pdflatex):

\documentclass[pdf]{standalone}
\usepackage{pstricks-add}
\usepackage{amsmath}
\DeclareMathOperator\re{Re}
\DeclareMathOperator\im{Im}

\begin{document}

$ begin{pspicture}
\psset{ticks=none, labels=none, arrowinset=0.2,arrows =c->, labelsep=3pt}
\psaxes{c->}(0,0)(5,5)[$\re (z)$,-90][$\im (z)$,180]
\pnodes(0,0){O}(3,1.6){Z}(1.6,3){B}(4.6,4.6){C}
\uput[l](B){$\beta $}\uput[r](Z){$z$}\uput[ur](C){$z +\beta $}
\ncline{O}{B}\ncline{O}{C}\ncline{Z}{C}
\psset{linestyle=dashed}
\ncline{O}{Z}\ncline{B}{C}
\end{pspicture} $

\end{document} 

enter image description here

5

Since you deal with vectors I suggest to use polar coordinate system instead Cartesian:

\documentclass[tikz,border=3mm]{standalone}
    \usetikzlibrary{arrows.meta}
\usepackage{amsmath}

    \begin{document}
\begin{tikzpicture}[>={Straight Barb[]}]
\draw[very thin,<->]    (0,4) node[below left]    {$\Im(z)$} -- (0,0) --
                        (5,0) node[below left]   {$\Re(z)$};
\draw[->]   (0,0) -- (45:3) coordinate[label=left:$\beta$] (beta);
\draw[dashed,very thin,->]    (beta) -- ++ (15:2)
                            coordinate[label=right  :$\beta+z$] (sum);
\draw[dashed,->]   (0,0) -- (15:2) coordinate[label=right:$z$] (z);
\draw[very thin,->]    (z) -- (sum);
\draw[thick,->] (0,0) -- (sum);
\end{tikzpicture}
    \end{document}

In determining coordinates for end of vectors I use absolute coordinate for (beta) and relative for (sum). For labeling of vectors I use label in coordinate.

enter image description here

In MWE, when asking here for help, I usually use standalone document class and additional packages, which is necessary to draw images or write a text, table etc.

Edit: I adopt thy vector styles to OP images. If the you don't like the way as are signed real and imaginary axis, you can replace \Im(z) with ``\text{Im}(z)''.

1

With MetaPost:

input latexmp
setupLaTeXMP(textextlabel=enable, mode=rerun, packages="amsmath");
numeric u; u = .75cm;
pair beta, re, im; beta = (u, 3u); re = (5u, 0); im = (0, 5u);
beginfig(1);
  z = u*(3, 1.5); 
  for M = re, im, beta, z+beta: drawarrow origin -- M; endfor
  drawarrow z--z+beta;
  drawoptions(dashed evenly);
  draw origin--z;
  draw beta -- z+beta;
  label.rt("$\text{Re}(z)$", re); label.lft("$\text{Im}(z)$", im);
  label.lrt("$z$", z); label.lft("$\beta$", beta);
  label.rt("$z+\beta$", z+beta);
endfig;
end.

With the command line, you get the (PostScript) figure by using the mpost command

mpost myfigure.mp

To convert it in a PDF figure, apply the mptopdf utility upon the resulting PostScript file:

mptopdf myfigure.1

If you do not use the command line, please refer to how your own TeX editor can handle MetaPost programs.

Result:

enter image description here

Another, more direct way to get the PDF figure: insert the code in a LuaLaTeX program, and use the luamplib package, as below. (Same result.)

\documentclass[border=2mm]{standalone}
\usepackage{luamplib, amsmath}
  \mplibtextextlabel{enable}
\begin{document}
  \begin{mplibcode}
     numeric u; u = .75cm;
     pair beta, re, im; beta = (u, 3u); re = (5u, 0); im = (0, 5u);
     beginfig(1);
       z = u*(3, 1.5); 
       for M = re, im, beta, z+beta: drawarrow origin -- M; endfor
       drawarrow z--z+beta;
       drawoptions(dashed evenly);
       draw origin--z;
       draw beta -- z+beta;
       label.rt("$\text{Re}(z)$", re); label.lft("$\text{Im}(z)$", im);
       label.lrt("$z$", z); label.lft("$\beta$", beta);
       label.rt("$z+\beta$", z+beta);
    endfig;
  \end{mplibcode}
\end{document}

You must log in to answer this question.

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