How to plot a curve in a polar form r = f(Θ)?

Can we use LaTeX to make the graph of $\rho = \sec(\theta)$?

-
Have a look at this question: tex.stackexchange.com/a/65447/15925 . – Andrew Swann Nov 24 '13 at 11:36
You have a list of your questions here. Some of them have already had answers. If the answers satisfied you, please kindly accept them by clicking the check mark button below the score labels. Optionally you should vote them up by clicking the upward arrow button. You can also vote them down but only for the extreme cases! – kiss my armpit Nov 24 '13 at 15:45

4 Answers

You can use pgfplots to achieve this:

\documentclass[tikz]{standalone}

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

\begin{document}
\begin{tikzpicture}
\begin{polaraxis}
\def\FREQUENCY{3}
\addplot[red,domain=0:360,samples=360,smooth] (x,{30-8*sin(\FREQUENCY*x)});
\addplot[dashed,domain=0:2*pi] (deg(x),30);
\addplot[mark=*,only marks] coordinates {(0,0)};
\end{polaraxis}
\end{tikzpicture}
\end{document}


The source code is self-explanatory for anyone who have minimal experience in LaTeX.

Note: pgfplots by default uses degrees, for using radians you then need to convert it to degree via deg() function.

And the \rho=\sec\theta (that's a pretty ugly function to plot it on the polar axis):

\documentclass[tikz]{standalone}

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

\begin{document}
\begin{tikzpicture}
\begin{polaraxis}
\addplot[red,domain=-42:42,samples=360,smooth] (x,{sec(x)});
\addplot[mark=*,only marks] coordinates {(0,0)};
\end{polaraxis}
\end{tikzpicture}
\end{document}


-
It is not \rho=\sec \theta. – kiss my armpit Nov 24 '13 at 11:50
@DonutE.Knot: I've added the \rho=\sec\theta. It's a straight line indeed. – m0nhawk Nov 24 '13 at 11:56

The polar with the corresponding cartesian plot:

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

\begin{document}
\begin{pspicture}(-3.5,-3.5)(3.5,3.5)
\psaxes[axesstyle=polar,subticklinestyle=dashed,subticks=2,labelFontSize=\scriptstyle](3,0)
\psplot[polarplot,algebraic,linecolor=red,linewidth=2pt,plotpoints=500,
yMaxValue=3.5]{Pi neg}{Pi}{1/(cos(x))}
\psplot[algebraic,linecolor=blue,plotpoints=5000,yMaxValue=3.5]{Pi neg}{Pi}{1/(cos(x))}
\end{pspicture}

\end{document}


If you want to see the calculated points use showpoints:

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

\begin{document}
\begin{pspicture}(-3.5,-3.5)(3.5,3.5)
\psaxes[axesstyle=polar,subticklinestyle=dashed,subticks=2,labelFontSize=\scriptstyle](3,0)
\psplot[polarplot,algebraic,linecolor=red,linewidth=1.5pt,plotpoints=25,showpoints,
yMaxValue=3.5]{Pi neg}{Pi}{1/(cos(x))}
\end{pspicture}

\end{document}


-

A recommended solution with PSTricks. \rho=\sec\theta represents the line x=1. So the correct curve should be like below.

\documentclass[border=12pt,pstricks]{standalone}

\usepackage{pst-plot}

\psset{runit=1.2cm,unit=\psrunit}
\pstVerb{/const 2 def}

\begin{document}
\begin{pspicture}(-3.5,-3.5)(3.5,3.5)
\psaxes[axesstyle=polar,subticklinestyle=dashed,subticks=2,labelFontSize=\scriptstyle](3,3)
\psplot[polarplot,algebraic=true,linecolor=red,linewidth=2pt,plotpoints=1000,yMaxValue=3.5,yMinValue=-3.5]{0}{TwoPi}{const/(cos(x))}
\end{pspicture}
\end{document}


-

My package xpicture plots polar curves (or more general, parametric curves).

For example

% Cardioide: r = 1+cos t
\SUMfunction{\ONEfunction}{\COSfunction}{\ffunction} % Define f(t)=1 + cos t
\POLARfunction{\ffunction}{\cardioide}  % Declare \cardioide as r=f(\phi)
% \degreespolarlabels              % Uncomment to label angles in degrees

\begin{center}
\def\runitdivisions{2}              % 2 divisions of unity in the r-axis
\setlength{\unitlength}{1.5cm}
\begin{Picture}(-2.5,-2.5)(2.5,2.5)
\polargrid{2}{16}  % Draw a polar grid for 0<r<2 and 16 divisions of circle
\pictcolor{blue}\linethickness{1pt}
\PlotParametricFunction[20]{\cardioide}{0}{\numberTWOPI}
% Draw \cardioide for 0<\phi<2\pi
\end{Picture}

$\rho=1+\cos\phi$
\end{center}


-