ListPolarPlot not showing full plot range even with PlotRange -> All

6

Bug introduced in 8.0 and fixed in 9.0


I have a list of data dpdOt (given below) with associated angular coordinates thetaplot, which when plotted using

    thetaplot = Table[tt,{tt,0,2*Pi,2*Pi/300}]
    ListPlot[Transpose[{thetaplot/Pi 180, dpdOt}], Joined -> True, PlotRange -> All]

looks like this:

ListPlot

However, I'd rather see this plotted as a ListPolarPlot, but I am having trouble with PlotRange. For example, when I use the command

    ListPolarPlot[Transpose[{thetaplot, dpdOt}], 
      Joined -> True, PolarAxes -> True, 
      PolarTicks -> {"Degrees", Automatic}, 
      PolarGridLines -> True, PlotRange -> All]

I get the following plot:

ListPolarPlot

which is obviously not plotting the full data range. If I try and manually set PlotRange -> 1.5, Mathematica merely gives me a zoomed out version of the same polar plot:

enter image description here

Does anybody have any idea how I can get Mathematica to show the full dataset on my polar plot?

The dataset is:

    dpdOt = {0.`, 0.009554081538201524`, 0.03657921246993372`,  0.07645719594918586`, 0.1224134613324866`, 0.16671965853831489`,  0.2020509236272155`, 0.22274769290832974`, 0.22575257105691635`,  0.21105662334588893`, 0.18158393497377667`, 0.14254991938921568`,   0.10042704400882534`, 0.06172261938230206`, 0.03180381202988293`,   0.013989865520678359`, 0.009074375607003422`, 0.015353199348562318`,   0.029133703291304467`, 0.045608259290746044`,  0.059907143344449666`, 0.06811602801815318`, 0.06805619079404875`,   0.05967798355792369`, 0.044998917623994925`, 0.027610426330823622`,   0.011863439428043385`, 0.001905442213411619`,  0.0007687312281260307`, 0.009696350336090554`,   0.027841942524898654`, 0.05240297090682485`, 0.07915899837109333`,   0.10330545634013048`, 0.12041455169350666`, 0.1273300195707255`,   0.12281593359315725`, 0.10782877955797118`, 0.08535664034364425`,   0.0598548826381265`, 0.0363874297112553`, 0.01964103546890816`,   0.013005632519217386`, 0.017901837073488084`, 0.03348933529492066`,   0.05681622331866217`, 0.08338356368455244`, 0.10801797869739073`,   0.1258838157458027`, 0.13343735028386552`, 0.12913464839968958`,   0.11375083606637912`, 0.09024321729842082`, 0.0631798709645865`,   0.03784184580594409`, 0.01917378839552386`, 0.010791123900980252`,   0.014244303123378875`, 0.028692550180028028`, 0.051059513247240756`,   0.07664648824951373`, 0.10008465443777814`, 0.11643545518106532`,   0.12221354284042615`, 0.11611806246510771`, 0.09931464269298441`,   0.07520186774030126`, 0.048703952993848255`, 0.025233271631061455`,   0.009540102126567822`, 0.004695564232203329`, 0.011429494446618007`,   0.027971655343629113`, 0.050436902199565224`, 0.07367569127391489`,   0.0924069287274574`, 0.10238447666431386`, 0.1013374846275298`,   0.08947198471813812`, 0.06941749674225801`, 0.04562682130072883`,   0.02336179577963223`, 0.007493854962987605`, 0.00139302722259097`,   0.006161200150237524`, 0.020388179378757983`, 0.04048931173627752`,   0.06154859929889949`, 0.078472675688499`, 0.08718681535608698`,   0.08559234035384577`, 0.07405894111973076`, 0.05533354561614883`,   0.03388451541925968`, 0.014833968423679648`, 0.0027301058954676103`,   0.00045163413523262254`, 0.008507481364097463`,   0.024903075095984252`, 0.0456105809967408`, 0.06553606471258362`,   0.0797558049558498`, 0.08472607856766433`, 0.0791726455592892`,   0.06443855291626575`, 0.04419570077716716`, 0.023577636442966548`,   0.007932512944609768`, 0.001492113602352463`, 0.006281152280129452`,   0.021542228899509474`, 0.04383535778027103`, 0.06781257671823812`,   0.08750405559279266`, 0.0978210472734063`, 0.09591516988165438`,   0.08205096374581881`, 0.05974878090823095`, 0.03511799119091121`,   0.015491056611719418`, 0.007644208098589879`, 0.016008842898051462`,   0.041308975498834125`, 0.0799920698716276`, 0.12466309845912157`,   0.16551502191459355`, 0.19251813998620537`, 0.1979365219231554`,   0.1786272840234142`, 0.1375777607510681`, 0.08425397825386047`,   0.0335534665496219`, 0.0034359646772461074`, 0.011591552251972725`,  0.07173765420231708`, 0.19026282194703806`, 0.3639239411625669`,   0.5791488923696507`, 0.813221884473814`, 1.037282176743776`,   1.2207136698253551`, 1.3362119128823164`, 1.3646459208863824`,   1.2988226517976427`, 1.1454201179472137`, 0.9246567650991964`,   0.6676574849266789`, 0.4118891574170705`, 0.19539424083596366`,   0.050782165477450084`, 0.`, 0.050782165477450084`,   0.19539424083596366`, 0.4118891574170705`, 0.6676574849266789`,   0.9246567650992072`, 1.1454201179472137`, 1.2988226517976427`,   1.3646459208863868`, 1.33621191288231`, 1.2207136698253502`,   1.0372821767437717`, 0.813221884473814`, 0.5791488923696507`,   0.36392394116255933`, 0.19026282194703142`, 0.07173765420231298`,   0.011591552251971629`, 0.0034359646772465858`,   0.033553466549622345`, 0.08425397825386129`, 0.13757776075106873`,   0.17862728402341452`, 0.1979365219231553`, 0.19251813998620523`,   0.16551502191459352`, 0.12466309845912063`, 0.07999206987162717`,   0.04130897549883387`, 0.016008842898051108`, 0.00764420809858988`,   0.015491056611719966`, 0.0351179911909119`, 0.05974878090823171`,   0.08205096374581904`, 0.0959151698816545`, 0.0978210472734063`,   0.08750405559279249`, 0.06781257671823812`, 0.04383535778027089`,   0.02154222889950937`, 0.006281152280129231`, 0.001492113602352463`,   0.0079325129446096`, 0.023577636442966645`, 0.044195700777166905`,   0.06443855291626631`, 0.0791726455592894`, 0.08472607856766434`,   0.07975580495584968`, 0.06553606471258311`, 0.045610580996740674`,   0.0249030750959836`, 0.008507481364097328`, 0.00045163413523252865`,   0.0027301058954676857`, 0.014833968423680205`,   0.033884515419259915`, 0.05533354561614951`, 0.07405894111973105`,  0.08559234035384577`, 0.08718681535608702`, 0.078472675688499`,   0.061548599298899026`, 0.04048931173627754`, 0.020388179378757657`,   0.006161200150237425`, 0.0013930272225909912`,   0.007493854962987713`, 0.023361795779632825`, 0.04562682130072909`,   0.06941749674225874`, 0.08947198471813836`, 0.10133748462752992`,   0.10238447666431386`, 0.0924069287274574`, 0.07367569127391442`,   0.05043690219956524`, 0.027971655343628703`, 0.011429494446618017`,   0.0046955642322033106`, 0.009540102126567813`,   0.025233271631062083`, .04870395299384845`, 0.07520186774030205`,   0.09931464269298464`, 0.11611806246510807`, 0.12221354284042608`,   0.11643545518106499`, 0.10008465443777788`, 0.07664648824951395`,   0.05105951324724025`, 0.028692550180028028`, 0.014244303123378665`,   0.010791123900980252`, 0.01917378839552417`, 0.03784184580594409`,   0.06317987096458702`, 0.09024321729842102`, 0.11375083606637972`,   0.1291346483996897`, 0.13343735028386566`, 0.1258838157458027`,   0.1080179786973901`, 0.08338356368455223`, 0.05681622331866127`,   0.03348933529492036`, 0.017901837073488223`, 0.013005632519217408`,   0.01964103546890816`, 0.03638742971125556`, 0.059854882638126314`,   0.0853566403436447`, 0.10782877955797118`, 0.12281593359315748`,   0.1273300195707255`, 0.12041455169350626`, 0.10330545634013014`,   0.07915899837109269`, 0.052402970906824456`, 0.027841942524897894`,   0.009696350336090289`, 0.0007687312281258732`,   0.0019054422134117427`, 0.011863439428043385`, 0.02761042633082383`,   0.044998917623994925`, 0.0596779835579238`, 0.06805619079404875`,   0.06811602801815296`, 0.05990714334444941`, 0.04560825929074557`,   0.029133703291304193`, 0.015353199348562014`, 0.009074375607003374`,   0.013989865520678902`, 0.031803812029883506`, 0.06172261938230317`,   0.10042704400882617`, 0.14254991938921568`, 0.18158393497377667`,   0.21105662334588893`, 0.22575257105691635`, 0.22274769290832974`,   0.2020509236272155`, 0.16671965853831489`, 0.1224134613324866`,   0.07645719594918586`, 0.03657921246993372`, 0.009554081538201524`,   0.`}

Matthew

Posted 2013-08-07T07:29:16.470

Reputation: 363

1I think you should show us some minimal data sample which reproduces this issue because I have no problem with my data. Also, which verion are you workin on? – Kuba – 2013-08-07T07:39:56.690

1Try PlotRangePadding -> 0 and/or ImagePadding -> 0 as well... please also include some sample data as well. I can't seem to reproduce it in some test data I created, but I do often encounter this annoyance with LPP – rm -rf – 2013-08-07T07:40:09.237

@rm-rf Neither PlotRangePadding or ImagePadding helps at all unfortunately. I've appended the dataset to the original post. Thanks again. – Matthew – 2013-08-07T08:07:29.327

@Kuba I'm working with version 8. – Matthew – 2013-08-07T08:08:27.537

There is not problem with dpdOt on V9 on WinXP. But does it also produce an error like Transpose[{thetaplot, dpdOt}] do? – Kuba – 2013-08-07T08:20:25.190

@Kuba Maybe (frustratingly) it's a v8 glitch then (I'm on OsX 10.8). I don't get any errors output though. – Matthew – 2013-08-07T08:23:58.433

Can't reproduce on v9, Mac OS X 10.8... screenshot

– cormullion – 2013-08-07T08:29:23.450

1I would label this a v8 bug. Reproduced on mma8 win7 and not mm9 win7. Btw your code snippets are not full working (thethaplot is not defined and pi should be Pi) – Ajasja – 2013-08-07T08:52:30.463

If you are interested in fixing this problem, and if the code for ListPolarPlot is still top-level, you could include its definition in your question for those with dedication to debug. Please use the Spelunk package to extract these definitions in a readable form.

– Mr.Wizard – 2013-08-07T08:57:27.940

Answers

9

So I agree with everyone. It seems to be a bug in version 8. I have managed to do a (rather ugly) work around, but it does the job. Basically I define an interpolation function based on the data:

    thetaplot = Table[tt,{tt,0,2*Pi,2*Pi/300}]
    interpfunc = Interpolation[Transpose[{thetaplot,dpdOt}]];

And then plot using the interpolation function.

    PolarPlot[interpfunc[tt], {tt, 0, 2*Pi}, PolarAxes -> True, PolarTicks -> {"Degrees",Automatic}, PolarGridLines -> True,  PlotRange -> All]

which gives me the full data range as desired:

enter image description here

Thanks everyone for your help. Much appreciated.

Matthew

Posted 2013-08-07T07:29:16.470

Reputation: 363

1+1 for providing your own work-around. If you are interested in a true bug-fix please see my comment above. – Mr.Wizard – 2013-08-07T08:59:10.477

@Mr.Wizard Thanks for the fix. Unfortunately this doesn't seem to work for me in v8. I tried it on a friend's version of Mathematica (v7) and it worked fine though. :) – Matthew – 2013-08-07T09:05:03.980

Pardon, what doesn't work? I did not provide a fix (yet) but merely an illustration. Do you mean that the Spelunk function (from the package linked in the comment) fails to read the definition of ListPolarPlot? If that is the case make sure you have first used the function to plot something as this will pre-load the definitions from stubs. – Mr.Wizard – 2013-08-07T09:08:07.517

@Mr.Wizard Sorry for the confusion...I merely meant that I could reproduce your plot in v7, but not in v8. I have not tried the Spelunk function yet. – Matthew – 2013-08-07T09:12:59.483

6

This appears to be a bug of sorts. Mathematica 7 produces this output for the given input:

ListPolarPlot[dpdOt, Joined -> True, PolarAxes -> True, 
 PolarTicks -> {"Degrees", Automatic}, PolarGridLines -> True, PlotRange -> All]

enter image description here

There's some clipping of the degree labels but the full range of data appears to be correctly plotted. In whatever version you are using All is apparently not handled correctly for this option.

Borrowing Mike's example we can see that in v7 the behavior is more logical:

Pane @ ListPolarPlot[dpdOt, Joined -> True, PolarAxes -> True, 
 PolarTicks -> {"Degrees", Automatic}, PolarGridLines -> True, PlotRange -> #, 
 Frame -> True] & /@ {0.6, 3} // Column

enter image description here

enter image description here

One can see that the restricted range is handled correctly, and the extended range while perhaps not ideal (IMHO it should extend the grid lines as well) at least doesn't break anything.

Mr.Wizard

Posted 2013-08-07T07:29:16.470

Reputation: 259 163

thats interesting. The stuff I just removed was done with V8 on mac. – Mike Honeychurch – 2013-08-07T08:53:44.400

0

This is somewhat marginal but I decided to try this in Presentations. I'm fairly certain it would work in V7 or V8 because the drawing of the polar grid is completely separate from the drawing of the curves. So here is what it looks like.

<< Presentations`

I hid sample data in the notebook but it's the same as dpdOt above.

sampleData = <<Sample polar data>>;

The following first draws the polar grid and then the curve on top of it. The limits of the polar grid, and the spacings, are given by ComplexPolar expressions, which are just radius and angle.

Draw2D[
 {DrawPolarGrid[{ComplexPolar[0, -\[Pi]], ComplexPolar[1.5, \[Pi]], 
    ComplexPolar[0.25, \[Pi]/4], {2, 4}}, PGLabelAxis -> \[Pi]/8,
   PGAngleNumberFunction -> (phrase[Round[#/Degree // N], Spacer[2], 
       "\[Degree]"] &)],
  ListPolarDraw[sampleData, Joined -> True, PlotStyle -> Red]},
 PlotRangePadding -> 0.25,
 ImageSize -> 300]

enter image description here

The following gives a close-up of the inner portion of the curve.

Draw2D[
 {DrawPolarGrid[{ComplexPolar[0, -\[Pi]], ComplexPolar[0.25, \[Pi]], 
    ComplexPolar[0.05, \[Pi]/4], {2, 4}}, PGLabelAxis -> \[Pi]/8,
   PGAngleNumberFunction -> (phrase[Round[#/Degree // N], Spacer[2], 
       "\[Degree]"] &)],
  ListPolarDraw[Clip[#, {0, 0.25}] & /@ sampleData, Joined -> True, 
   PlotStyle -> Red, PlotRange -> 0.25]},
 PlotRangePadding -> 0.01,
 ImageSize -> 300]

enter image description here

David Park

Posted 2013-08-07T07:29:16.470

Reputation: 2 503