4

In R it's easy to do something like

x <- seq(0, 2*pi, 0.01)
plot(sin(x), cos(3*x), type='line')

to get the plot

enter image description here

How can I make such a plot using tikz/pgfplots?

  • 3
    Might be an idea to explain the ~ syntax you use in the title. – daleif Aug 22 '15 at 11:36
12

It is also easy with pgfplots

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[domain=0:360,samples=101,no marks] ({sin(x)},{cos(3*x)});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • I'd say: easier and prettier. – Sigur Aug 22 '15 at 15:09
  • 2
    +1 . Since this is an answer to a beginner question, I would like to advertise that \pgfplotsset{trig format plots=rad} in the preamble would reconfigure all plots to use radians. In this case, one could also write domain=0:2*pi to get the same outcome. – Christian Feuersänger Aug 22 '15 at 15:13
  • @ChristianFeuersänger Also may I suggest an alias for the compat key as assume version or somoething along those lines? That would make the users aware that there are compatibility options and also assume version=newest becomes a literal. – percusse Aug 22 '15 at 15:36
  • In principle: yes... but I am not sure if I want to substitute its occurrences in all examples. But that, in turn, would be necessary in order to make people aware of its existence. [...] – Christian Feuersänger Aug 22 '15 at 18:43
  • [...] And if they are not aware of it, it will add confusion rather than clarification, especially since compat is an established best-practise and people are used to it. And since assume version=newest sounds as if that would be a good idea, I would even more say that I would rather discourage people from it and not at the alias (newest is often a bad idea, see tex.stackexchange.com/questions/139690/…). With this reasoning, I would rather not follow the suggestion. If in doubt, let us discuss it by email. – Christian Feuersänger Aug 22 '15 at 18:44

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.