1

Do my first steps with datavisualization. Find out how to plot functions. But the fourth function ist not in the plot. Found out that only the first three appear to be plotted out of the box. How can I make all four functions visible?

I would also like to have markings on the x axis in multiples of pi/2 and the label {\omega t} and stretch the plot double in y-direction.

\documentclass[border=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{datavisualization}
\usetikzlibrary{datavisualization.formats.functions}
\begin{document}
\begin{tikzpicture}

\datavisualization [school book axes,
                    y axis=grid,
                    visualize as smooth line/.list={sinU,sinI,cosvarphi,sinP},
                    style sheet=strong colors,
                    style sheet=vary dashing,
                    sinU={label in legend={text=$U$}},
                    sinI={label in legend={text=$I$}},
                    cosvarphi={label in legend={text=$\cos(\varphi)$}},
                    sinP={label in legend={text=$P$}},
                    data/format=function
                    ]
data [set=sinU] {
  var x : interval [-0.25*pi:2.25*pi];
  func y = sin((\value x +pi/6) r);
}
data [set=sinI] {
  var x : interval [-0.25*pi:2.25*pi];
  func y = sin((\value x -pi/6) r);
}
data [set=cosvarphi] {
  var x : interval [-0.25*pi:2.25*pi];
  func y = 0.5;
};
data [set=sinP] {
  var x : interval [-0.25*pi:2.25*pi];
  func y = 0.5 - cos((\value x *2) r);
};

\end{tikzpicture}
\end{document}

enter image description here

5
  • 1
    Remove ; after third set of function drawing (due to it the last in not considered).
    – Zarko
    Jan 31, 2021 at 17:36
  • @Zarko Thanks, it is a small piece of code, that makes the difference. Perhaps someone can me show the trick with the markings and the stretching?
    – Michael.H
    Jan 31, 2021 at 17:48
  • Sorry, I don't understand what you like to tel me. Noted error in your code is independent from number of drawing lines. In TikZ documentation so far I didn't found that any limitation about number of functions, which can be drawn. So. please correct this error and then provide MWE, which reproduce your problem.
    – Zarko
    Jan 31, 2021 at 18:42
  • @Zarko Please read my second paragraph in the question.
    – Michael.H
    Jan 31, 2021 at 18:47
  • Please one problem per question please. From question title follows, that your main problem (which is solved by comment) is number of visualized function. About your second problem, see /tikz/data visualization/tick typesetter on page 902, manual for TikZ & PGF, version 3.1.8b.
    – Zarko
    Jan 31, 2021 at 19:06

0

You must log in to answer this question.

Browse other questions tagged .