Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't figure how to draw a line with PolarPlot.

A vertical line through a is $r \cos(\theta) = a$, so

PolarPlot[a/Cos[theta], {theta, -Pi, Pi}]


A horizontal line through b is $r \sin(\theta)=b$, so

PolarPlot[b/Sin[theta], {theta, -6, 6}] 

works. (Using {theta, -Pi, Pi} doesn't work because of dividing by $\sin(0)=0$ I guess.)

How do I draw a radial line with $\theta = \pi/3$? Should be a line with slope $\tan(\pi/3)$. Can it be done with PolarPlot? I guess not since you have to give a function of $r$.

share|improve this question
Related question: "how do I draw the line $x=1$ using only Plot[]?" – J. M. Apr 29 '13 at 3:59
You can't draw this exactly but you can define a tangent arc of arbitrarily large radius which passes through the origin at the angle you want. Try creating a circle with variable radius which you can get to cut through (0,0) and then increase the radius until it looks like you want it to. – Jonathan Shock Apr 29 '13 at 5:11
Can't you just use Epilog for this goal? – Sjoerd C. de Vries Apr 29 '13 at 5:45

My friend, what you ask for is madness. Assuming you're completely aware of just doing this, or similar:

 PolarPlot[{4/Cos[theta], 4/Sin[theta]}, {theta, -6, 6}],
 Graphics[Rotate[Line[500 {{-1, 0}, {1, 0}}], Pi/3]]]

enter image description here

Here's the most obvious brute-force mickey mouse approach:

PolarPlot[{4/Cos[theta], 4/Sin[theta], Evaluate[
   If[Pi/3 < theta < Pi/3 + 4/(2 Pi Abs[#]), #] & /@
    Range[-30, 30, .717]
   ]}, {theta, -6, 6}, PlotRange -> 40, PlotPoints -> 400,
 PlotStyle -> {{Thickness[.01]}, {Thickness[.01]}, Thickness[.01]}]

enter image description here

Exchanging some accuracy for performance:

PolarPlot[{4/Cos[theta], 4/Sin[theta],
  If[Pi/3 < theta < Pi/3 + .03, Range[-30, 30, .717]]
  }, {theta, -6, 6}, PlotRange -> 40, PlotPoints -> 400,
 PlotStyle -> {Thickness[.01], Thickness[.01], Thickness[.01]}]

enter image description here

I mention these to show how arbitrary your functions in Plots can be.

Here's one implementation of @Jonathan's idea:

PolarPlot[{4/Cos[theta], 4/Sin[theta], .2/(theta - Pi/3)},
 {theta, -2.1 Pi, 2.1 Pi}, PlotRange -> 40]

enter image description here

Another, flakier version:

PolarPlot[{4/Cos[theta], 4/Sin[theta], 10000 (theta - Pi/3)},
 {theta, -2.1 Pi, 2.1 Pi}, PlotRange -> 40]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.