4

I wish to plot the curve defined by the parametric equations x = 1+sin t,y = 3 + 3(cos t)^3, such that the region bounded by this curve is shaded. As far as the code goes, I can't seem to find a similar example online to help me, so I don't have a starting point to work from. Any help plotting this curve would be much appreciated. I would like a basic set of axes to go with it, labelled x and y with an O to mark the origin.

1
3

Another way without using \clip is the following:

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[blue] plot[smooth,domain=-90:90,variable=\t] ({1+sin(\t)},{3 + 3(cos \t)^3}) 
            plot[smooth,domain=90:270,variable=\t] ({1+sin(\t)},{3 + 3(cos \t)^3});
\draw[-latex] (0,0) node[left] {$O$}-- (3,0) node[below]{$x$};
\draw[-latex] (0,0) -- (0,2) node[left]{$y$};
\end{tikzpicture}
\end{document}

enter image description here

2
  • Same question as for Marmot: How come that half of this curve is below the x-axis ? y = 3+3(cos t)^3 is always positive. Jan 16 '18 at 19:58
  • 1
    The problem is that the 3(cos \t)^3 that appears in each coordinate doesn't get parsed correctly. This can be fixed by making the multiplication explicit: 3*(cos \t)^3. Feb 19 '19 at 17:02
3

Error corrected, thanks to Franck Pastor!

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
 \draw[-latex] (0,0) node[left] {$O$}-- (3,0) node[below]{$x$};
 \draw[-latex] (0,0) -- (0,6) node[left]{$y$};
 \clip plot[smooth,samples=36,domain=0:360,variable=\t] ({1+sin(\t)},{3 + 3*(cos
 (\t))^3});
 \draw[fill=blue,opacity=0.8] (0,0) rectangle (2,6);
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

4
  • How come that half of the curve is below the x-axis ? y = 3+3(cos t)^3 is always positive… Am I missing something? Jan 16 '18 at 19:57
  • @FranckPastor That's a very good point!
    – user121799
    Jan 16 '18 at 20:07
  • What does the option [-latex] do to the \draw commands? Feb 19 '19 at 17:07
  • 1
    @AnnieCarter It adds an arrow head of the latex type, which looks arguably nicer than what you get with ->.
    – user121799
    Feb 19 '19 at 17:09
2

Here is a try with MetaPost, inserted in a LuaLaTeX program for convenience. With MetaPost, the parametric curve can be closed and then filled by making it a cycle (.. cycle instruction), right as it's about to join itself.

\documentclass[border=3mm]{standalone}
\usepackage{luatex85, luamplib}
\begin{document}
\begin{mplibcode}
u := cm; xmax = 2.25; ymax = 6.25;
vardef f(expr t) = 1 + sind t enddef;
vardef g(expr t) = 3 + 3((cosd t)**3) enddef;
path curve;
beginfig(1); 
    % Axes and Labels
    drawarrow origin -- (xmax*u, 0);
    label.llft(btex $O$ etex, origin); 
    label.bot(btex $x$ etex, (xmax*u, 0));
    drawarrow origin -- (0, ymax*u);
    label.lft(btex $y$ etex, (0, ymax*u));
    % Filled Curve
    curve = ((f(0), g(0)) for t = 1 upto 359: .. (f(t), g(t)) endfor .. cycle) scaled u;
    fill curve withcolor blue;
endfig;
\end{mplibcode}
\end{document}

enter image description here

2

Here's a very slight variation on user's answer which doesn't require finding coordinates for the shaded region:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
 \draw[-latex] (0,0) node[left] {$O$}-- (3,0) node[below]{$x$};
 \draw[-latex] (0,0) -- (0,6) node[left]{$y$};
 \begin{scope}[fill=blue,opacity=0.8]
  \fill[clip] plot[smooth,samples=36,domain=0:360,variable=\t] ({1+sin(\t)},{3 + 3*(cos
 (\t))^3});
 \end{scope}
\end{tikzpicture}
\end{center}
\end{document}
1

Here's yet another way to doing it using \filldraw:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
 \draw[-latex] (0,0) node[left] {$O$}-- (3,0) node[below]{$x$};
 \draw[-latex] (0,0) -- (0,6) node[left]{$y$};
 \filldraw[blue!80] plot[smooth,samples=36,domain=0:360,variable=\t] ({1+sin(\t)},{3 + 3*(cos
 (\t))^3});
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

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.