I'm struggling to generate rose plots that have the ability to plot multiple measurands that can be both positive and negative. Here's an example of something (from Excel !) that I seem to be having trouble generating in Mma.
You notice I am plotting multiple datasets which have positive and negative quantities, as a function of wind bearing. This sort of thing is typically used for displaying wind yaw misalignment of a wind turbine measured by a lidar operating at multiple ranges.
ListPolarPlot is a bit of a non-starter, as the centre of the plot is always at zero (I'd like it at, say, -10). SectorChart doesn't handle this sort of thing either. The solutions to similar questions on stackoverflow don't seem to be applicable: they plot positive quantities, and sometimes don't allow multiple datasets to be combined.
I need something like a ListCircularPlot !
Anything that avoid me having to use all graphics primitives is appreciated.
Thanks
-
$\begingroup$ If you know your data is always above 10, then why not preprocess the data (by subtracting 10) and then use ListPolarPlot? $\endgroup$– bill sFeb 20, 2018 at 16:04
-
$\begingroup$ Thanks Bill. Yes, I've done that - but then how do I label the radial axis easily ? $\endgroup$– ouzelFeb 20, 2018 at 16:34
-
$\begingroup$ Possible duplicate: mathematica.stackexchange.com/questions/31257/…, maybe also mathematica.stackexchange.com/questions/128330/… $\endgroup$– Michael E2Feb 20, 2018 at 16:53
-
$\begingroup$ They are not duplicates, as none of those plotted negative data. I did look at them before posting, but thanks for checking. $\endgroup$– ouzelFeb 21, 2018 at 11:28
2 Answers
You can use ListPolarPlot
and modify the ticks to show negative radial values. Here's some data:
data = Range[-30, 30];
And the plot:
ListPolarPlot[
data+30, (* rescale data *)
PolarAxes->True,
PolarGridLines->{Automatic, Range[-30,30,10]+30},
PolarTicks->{Automatic, Thread[{Range[0,60,10], Range[0,60,10]-30}]}
]
Addendum
(The OP requested to put the origin at the top as well)
There is no simple way to put the origin at the top. One workaround is to modify your data so that it starts at $90^\circ$ and then modify the ticks as well. Here is some sample data:
data = Thread[{Range[0, 360, 10] Degree, Range[-18, 18]}];
We need to translate both the angle and the radius, which can be done using TranslationTransform
(and in many other ways as well). The following ListPolarPlot
call translates the data and modify the ticks:
ListPolarPlot[
TranslationTransform[{90 Degree, 18}][data],
PolarAxes->True,
PolarTicks->
{
Table[{x, Mod[x+270, 360]} Degree, {x, 0,360, 10}],
Table[{x, x-20}, {x, 0, 40, 10}]
},
PolarGridLines -> {Automatic, {10,20,30,40}}
]
-
$\begingroup$ The above looked to be a great solution, but alas does not work for me due to a flaw (bug ?) in mma v7 e.g. see: ! photos.app.goo.gl/HBtu2WrKZGhCRByk2 (hope that graphics link thing works) Basically mma 7 reports an error: "PolarAxes::polarticks: Value of PolarTicks -> {{0,270 [Degree]},{10 [...][Degree],250 [Degree]},{350 [Degree],260 [Degree]},{360 [Degree],270 [Degree]}} should be None, Automatic, or a list of tick specifications. >>" And does so even for its own help documentation examples using PolarTicks. So I suppose I am a bit stuck ! $\endgroup$– ouzelFeb 26, 2018 at 17:18
-
$\begingroup$ @ouzel I don't have M7 available to test, but perhaps you can try using
Table[{N@x, Mod[x+270, 360]} Degree, {x, 0,360, 10}]
instead? $\endgroup$ Feb 26, 2018 at 18:12 -
$\begingroup$ Thanks Carl, but still broken. Perhaps the PolarTicks issue is a problem with Windows Mma v7 :-( $\endgroup$– ouzelFeb 27, 2018 at 10:00
-
$\begingroup$ And I needed the polar angle increasing monotonic clockwise (to fit with the conventional definition of an angle bearing) ! $\endgroup$– ouzelFeb 27, 2018 at 11:58
-
$\begingroup$ But that can be done by negating the angle of the initial data e.g. Map[{- #[[1]], #[[2]]} &,data] as well as appropriate choice of PolarTicks (in non v7) $\endgroup$– ouzelMar 8, 2018 at 15:07
In versions 12.2+, you can use RadialAxisPlot
:
RadialAxisPlot[{{9,- 7, 8,-5, 5,1},
{-3, 2,- 3, 1, 8, 5},
{2, -8, 3,- 4, 1, 9}},
Filling -> False,
PlotMarkers -> ChartElementData["CenterMarkers"],
PlotLegends -> {"legend 1", "legend 2", "legend 3"}]
RadialAxisPlot[{{9,- 7, 8,-5, 5,1},
{-3, 2,- 3, 1, 8, 5},
{2, -8, 3,- 4, 1, 9}},
GridLines -> "Polygon",
PlotMarkers -> ChartElementData["CenterMarkers"],
PlotLegends -> {"legend 1", "legend 2", "legend 3"}]