Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How to disable rounding up the radius which is used to calculate the origin of the polar axes with the option PolarAxesOrigin? Example:

PolarPlot[Sqrt[n], {n, 0, 20}, PolarAxes -> True,
PolarAxesOrigin -> {0, 7}, PolarTicks -> {"Degrees", Automatic}]

polar plot

It rounds 7 to 8, 13 to 15 and 521 to 600.

share|improve this question
    
Added the bugs tag. Feel free to remove it if I made a mistake –  belisarius Dec 19 '13 at 21:29
    
Should I report it to customer support? –  shrx Dec 19 '13 at 21:31
    
I'd suggest waiting for a day or o to see if someone else can find a workaround –  belisarius Dec 19 '13 at 21:50
add comment

3 Answers 3

It seems like PolarPlot uses FindDivisions internally to generate the ticks and chooses the last point as the origin, which causes this behaviour:

FindDivisions[{0, 7}, 4]
(* {0, 2, 4, 6, 8} *)

This is in fact described in the documentation for FindDivisions (under "Details and Options"):

The first and last numbers may be slightly outside the range $x_\min$ to $x_\max$

I've run into similar subtle quirks with PolarPlot – especially when styling/customizing it a particular way — and usually end up writing my own version of PolarPlot using graphics primitives.

share|improve this answer
add comment

The simplest workaround:

PolarPlot[Sqrt[n], {n, 0, 20}, PolarAxes -> {True, False}, 
 PolarAxesOrigin -> {0, 7}, PolarTicks -> {"Degrees", Automatic}, 
 Axes -> {True, False}]

enter image description here

share|improve this answer
    
Thanks, I could almost use this, I just need to figure out how to perform Abs[] on major ticks while preserving the minor ticks, and how to cut off the axes at [-7,7]. Will look into it now. –  shrx Dec 29 '13 at 21:09
add comment

I have contacted Technical Support and they have confirmed this to be a bug. They have also provided the following workaround:

plot = PolarPlot[7 Sin[x], {x, 0, 2 Pi}, PolarAxesOrigin -> {0, 7}, 
PolarAxes -> True]

initial plot

(* Rescale the circular part. *)
plot[[1, 5, 1]] = Scale[plot[[1, 5, 1]], {7/8, 7/8}];

(* Remove the tick "8". *)
Cases[plot[[1, 5, 2]], Text[___], Infinity]
{Text[0., Offset[{0, -8}, Scaled[{0., -0.006}, {0, 0}]], {-1, 0}], 
Text[2., Offset[{0, -8}, Scaled[{0., -0.006}, {2, 0}]], {-1, 0}], 
Text[4., Offset[{0, -8}, Scaled[{0., -0.006}, {4, 0}]], {-1, 0}], 
Text[6., Offset[{0, -8}, Scaled[{0., -0.006}, {6, 0}]], {-1, 0}], 
Text[8., Offset[{0, -8}, Scaled[{0., -0.006}, {8, 0}]], {-1, 0}]}
Position[plot[[1, 5, 2]], Text[___], Infinity]
{{4, 1}, {4, 2}, {4, 3}, {4, 4}, {4, 5}}
plot[[1, 5, 2]] = Delete[plot[[1, 5, 2]], {{4, 5}}];
plot

plot with fixed origin

share|improve this answer
add comment

Your Answer

 
discard

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.