# How to draw a function like sin(x)~cos(x) in tikz/pgfplots?

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

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

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

It is also easy with pgfplots

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}

• +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
• [...] 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