-1

How to plot a trefoil like this in Tikzpicture? enter image description here

5
  • 4
    What have you done so far, to draw this picture? It is quite unlikely, that people are willing to help you, if you showed no effort to solve your problem. This is a plattform for learning Tex not for outsourcing your work.
    – JMP
    Commented Apr 15, 2016 at 9:52
  • Do you have parametric equations for it at least? See if section 22.5 Plotting a function in pgfmanual.pdf helps. Commented Apr 15, 2016 at 9:53
  • 1
    related tex.stackexchange.com/questions/17181/…
    – percusse
    Commented Apr 15, 2016 at 10:51
  • 1
    This is the fourth picture you've outsourced. How many do you have to go? I understand that you might have initially had no idea how to even start, but you can presumably at least begin by setting up the basic document and tikzpicture environment now. Or, if not, then the answers provided to your other questions have not been of much help to you.
    – cfr
    Commented Apr 15, 2016 at 12:07
  • @TorbjørnT. Yes! Cos[t]^2 (-1 + 4 Sin[t]^2), Cos[t] Sin[t] (-1 + 4 Sin[t]^2)
    – Andrea Leo
    Commented Apr 16, 2016 at 19:40

1 Answer 1

4

As I alluded to, you basically only have to copy an example from section 22.5 in the manual for TikZ and replace the equations with the ones you want. In the first example note that the r indicates that radians should be used, by default the trigonometric functions in pgf uses degrees.

I also added an example with pgfplots, which is convenient if you need axes.

enter image description here

\documentclass[border=4mm]{standalone} 
\usepackage{pgfplots} % also loads tikz
\begin{document}              
\begin{tikzpicture}
\draw[domain=0:pi,variable=\t,samples=200]
plot ({cos(\t r)^2*(-1 + 4*sin(\t r)^2)},{cos(\t r)*sin(\t r)*(-1 + 4*sin(\t r)^2)});
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[
  axis lines=middle,
  trig format=rad,
  domain=0:pi,
  samples=200,
  width=4cm,
  axis equal]
\addplot [black] ({cos(x)^2*(-1 + 4*sin(x)^2)},{cos(x)*sin(x)*(-1 + 4*sin(x)^2)});
\end{axis}
\end{tikzpicture}
\end{document}
2
  • Thank you so much! The problem is that I can't figure out why the package pgfplots '' is not found ''..
    – Andrea Leo
    Commented Apr 16, 2016 at 20:33
  • @AndreaLeo Because it's not installed presumably. Anyway, if all you need is the trefoil itself, use the first example, and replace pgfplots with tikz. Commented Apr 16, 2016 at 20:40

You must log in to answer this question.

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