5

I decided to use TikZ datavisualization because of many possibilities:

  • adjustments for axes, grid, legend and ticks
  • automatic placement of labels and legend
  • automatic drawing of data value sets
  • style sheet vary dashing: Possibility to differ a set of vectors, even if one using black-white printing.

Here my code:

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{datavisualization.formats.functions}
\newcommand\U[1]{\underline U_{#1}}
\begin{document}
  \begin{tikzpicture}
    \datavisualization[
                       scientific axes={clean, end labels},
                       all axes = {ticks = {major at = 0}},
                       x axis = {label = Re},
                       y axis = {label = Im},
                       visualize as line/.list = {U_R, I, U_L, U_C, U},
                       style sheet = vary dashing,
                       I = {label in legend = {text = $\underline I$}},
                       U_R = {label in legend = {text = $\U{R}$}},
                       U_L = {label in legend = {text = $\U{L}$}},
                       U_C = {label in legend = {text = $\U{C}$}},
                       U = {label in legend = {text = $\U{}$}}
                      ]
    data[set = U_R] {
                     x, y
                     0, 0
                     2, 0
                    }
    data[set = I] {
                   x, y
                   0, 0
                   4, 0
                  }
    data[set = U_L] {
                     x, y
                     2, 0
                     2, 2
                    }
    data[set = U_C] {
                     x,   y
                     2.1, 2
                     2.1, 1
                    }
data[set = U] {
               x, y
               0, 0
               2, 1
              };
  \end{tikzpicture}
\end{document}

And the result:

result

I wish:

  1. Each vector should ends (as far as possible automatically) with an arrow tip.
  2. Angle for the vector U. Something like this (picture from above, modified with a graphic program):

resault1

Of course one can use something like (TikZ & PGF manual page 44):

result2

or (TikZ & PGF manual page 361):

result3

But in both cases one have a lot of "hand work" and less possibilities for adjustments.

Thank you for your help in advance!

5

With use of TikZ libraries angles and quotes (for second sub-question) and added option every visualizer/.style={->}, for the first sub-question, your MWE gives:

enter image description here

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{angles,datavisualization.formats.functions,quotes}
\newcommand\U[1]{\underline U_{#1}}
\begin{document}
  \begin{tikzpicture}
    \datavisualization[
                       scientific axes={clean, end labels},
                       all axes = {ticks = {major at = 0}},
                       x axis = {label = Re},
                       y axis = {label = Im},
                       visualize as line/.list = {U_R, I, U_L, U_C, U},
                       style sheet = vary dashing,
                       I = {label in legend = {text = $\underline I$}},
                       U_R = {label in legend = {text = $\U{R}$}},
                       U_L = {label in legend = {text = $\U{L}$}},
                       U_C = {label in legend = {text = $\U{C}$}},
                       U = {label in legend = {text = $\U{}$}},
                       every visualizer/.style={->}, % <-- added fo first sub-question
                      ]
    data[set = U_R] {
                     x, y
                     0, 0
                     2, 0
                    }
    data[set = I] {
                   x, y
                   0, 0
                   4, 0
                  }
    data[set = U_L] {
                     x, y
                     2, 0
                     2, 2
                    }
    data[set = U_C] {
                     x,   y
                     2.1, 2
                     2.1, 1
                    }
data[set = U] {
               x, y
               0, 0
               2, 1
              };
% added for second sub-question
\coordinate (A) at (2.5,1.5);
\coordinate (B) at (2.5,0);
\coordinate (C) at (0,0);
\pic [draw, angle radius=11 mm, "$\phi$"] {angle = B--C--A};

  \end{tikzpicture}
\end{document}
  • Hello @Torbjørn T. and @Zarko! Thank you both for the wonderful solution! – Su-47 Feb 20 '17 at 18:57

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.