13

I would like to draw bouquet of n circles. How can i draw it in Tikz?

enter image description here

rose with four petals is like i want to draw but with n petals.

juliohm
  • 3,452

2 Answers2

20

Some inspiration for an answer:

\documentclass{article}

\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=newest}

\begin{document}

 \begin{tikzpicture}
   \begin{polaraxis}[grid=none, axis lines=none]
     \addplot[mark=none,domain=0:360,samples=300] {cos(x*3)};
   \end{polaraxis}
 \end{tikzpicture}

\end{document}

which gives us

Image 1

And courtesy of my buddy percusse:

\documentclass{standalone}

\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=newest}

\begin{document}

 \begin{tikzpicture}
   \begin{polaraxis}
     \addplot[mark=none,domain=0:360,samples=300] {cos(5*x)};
   \end{polaraxis}
 \end{tikzpicture}

\end{document}

Image 2

It's important to observe that the secret relies in

cos(n*x)

where n is the number of petals you want. But note that when n is odd, you will end up with n petals, and 2n petals when n is even. If somebody could improve the code, it would be great. :)

Update: tohecz provided me an alternate plot which surely helps us here. Although he claims it's not a smooth curve, it's good enough for me. :)

Let's replace

cos(n*x)

by

abs(cos(n*x/2))

and voilà!

\documentclass{article}

\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=newest}

\begin{document}

 \begin{tikzpicture}
   \begin{polaraxis}[grid=none, axis lines=none]
     \addplot[mark=none,domain=0:360,samples=300] { abs(cos(6*x/2))};
   \end{polaraxis}
 \end{tikzpicture}

\end{document}

And we have:

Image 3

Yay! :)

Paulo Cereda
  • 44,220
9

There are 4 options in PSTricks.

r = f(Θ) in algebraic

Radial distance is a function of angle in algebraic form.

\begin{pspicture}(-1,-1)(1,1)
    \psplot[algebraic,polarplot,linecolor=red]{0}{TwoPi}{cos(3*x)}
\end{pspicture}

x = f(t) and y = g(t) in algebraic

Both x and y are functions of t in algebraic form.

\begin{pspicture}(-1,-1)(1,1)
    \psparametricplot[algebraic,linecolor=green]{0}{TwoPi}{cos(3*t)*cos(t)|cos(3*t)*sin(t)}
\end{pspicture}

r = f(Θ) in RPN

Radial distance is a function of angle in RPN form.

\begin{pspicture}(-1,-1)(1,1)
    \psplot[polarplot,linecolor=blue]{0}{TwoPi RadtoDeg}{3 x mul cos}
\end{pspicture}

x = f(t) and y = g(t) in RPN

Both x and y are functions of t in RPN form.

\begin{pspicture}(-1,-1)(1,1)
    \psparametricplot[linecolor=orange]{0}{TwoPi RadtoDeg}{3 t mul cos t PtoC}
\end{pspicture}

Complete Code

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\psset{plotpoints=150}

\def\Label#1{\uput[90](0,1){\tiny$n=#1$}}

\def\Draw#1{%
% r = f(Θ) in algebraic
\begin{pspicture}(-1,-1)(1,1)
    \psplot[algebraic,polarplot,linecolor=red]{0}{TwoPi}{cos(#1*x)}
    \Label{#1}
\end{pspicture}
% x = f(t) and y = g(t), both are in algebraic
\begin{pspicture}(-1,-1)(1,1)
    \psparametricplot[algebraic,linecolor=green]{0}{TwoPi}{cos(#1*t)*cos(t)|cos(#1*t)*sin(t)}
    \Label{#1}
\end{pspicture}
% r = f(Θ) in RPN
\begin{pspicture}(-1,-1)(1,1)
    \psplot[polarplot,linecolor=blue]{0}{TwoPi RadtoDeg}{#1 x mul cos}
    \Label{#1}
\end{pspicture}
% x = f(t) and y = g(t), both are in RPN
\begin{pspicture}(-1,-1)(1,1)
    \psparametricplot[linecolor=orange]{0}{TwoPi RadtoDeg}{#1 t mul cos t PtoC}
    \Label{#1}
\end{pspicture}}

\begin{document}
\multido{\i=1+1}{5}{\Draw{\i}}
\end{document}

enter image description here