polar plot - which series to use?

Laro88 4 years ago in API • updated 4 years ago 8
Which Series should be used in a polar plot?
I have some polar coordinates in a SortedList<double,double> however scatter and line results in hickups. The samples are heavily focused on Function series, hence not much help there with regards to polar plotting

Can you post some sample code?
There is not much to sample :-)
SortedList<double, double> _d = new SortedList<double, double>();  _d.Add(0, 23); _d.Add(90, 24); _d.Add(187, 25); _d.Add(192, 23); _d.Add(270, 25.5);      var ls = new OxyPlot.Series.LineSeries();//.ScatterSeries();//..LineSeries();  ls.Title = "dummy";  //ls.YAxisKey = plotdav.PlotID.ToString();  ls.ItemsSource = _d;  ls.DataFieldX = "Key";  ls.DataFieldY = "Value";  model.Series.Add(ls);
The problem seems to lie in the data binding - what is the appropriate series to use?
You have to use XYAxisSeries.

Therefore you need to inherit from this class.

CustomXYAxisSeries plotItem = new CustomXYAxisSeries ();
plotItem.EndPoint = new DataPoint(0, 23);

Let me know if it works...

Sample code: ..\Source\Examples\ExampleLibrary\Discussions\DiscussionExamples.cs

[Example("#549839: Polar plot with custom arrow series")]
public static PlotModel PolarPlotWithArrows()
var model = new PlotModel { Title = "Custom arrow series", PlotType = PlotType.Polar, PlotAreaBorderColor = OxyColors.Undefined };
model.Axes.Add(new AngleAxis { Minimum = 0, Maximum = 360, MajorStep = 30, MinorStep = 30, MajorGridlineStyle = LineStyle.Dash });
model.Axes.Add(new MagnitudeAxis { Minimum = 0, Maximum = 5, MajorStep = 1, MinorStep = 1, Angle = 90, MajorGridlineStyle = LineStyle.Dash });
model.Series.Add(new ArrowSeries549839 { EndPoint = new DataPoint(1, 40) });
model.Series.Add(new ArrowSeries549839 { EndPoint = new DataPoint(2, 75) });
model.Series.Add(new ArrowSeries549839 { EndPoint = new DataPoint(3, 110) });
model.Series.Add(new ArrowSeries549839 { EndPoint = new DataPoint(4, 140) });
model.Series.Add(new ArrowSeries549839 { EndPoint = new DataPoint(5, 180) });
return model;

private class ArrowSeries549839 : XYAxisSeries
private OxyColor defaultColor;

public ArrowSeries549839()
this.Color = OxyColors.Automatic;
this.StrokeThickness = 2;

public DataPoint StartPoint { get; set; }

public DataPoint EndPoint { get; set; }

public OxyColor Color { get; set; }

public double StrokeThickness { get; set; }

protected override void SetDefaultValues(PlotModel model)
if (this.Color.IsAutomatic())
this.defaultColor = model.GetDefaultColor();

public OxyColor ActualColor
return this.Color.GetActualColor(this.defaultColor);

public override void Render(IRenderContext rc, PlotModel model)
// transform to screen coordinates
var p0 = this.Transform(this.StartPoint);
var p1 = this.Transform(this.EndPoint);

var direction = p1 - p0;
var normal = new ScreenVector(direction.Y, -direction.X);

// the end points of the arrow head, scaled by length of arrow
var p2 = p1 - (direction * 0.2) + (normal * 0.1);
var p3 = p1 - (direction * 0.2) - (normal * 0.1);

// draw the line segments
rc.DrawLineSegments(new[] { p0, p1, p1, p2, p1, p3 }, this.ActualColor, this.StrokeThickness);
The Minimum and Maximum is not respected in the magnitude axis. So plotting below min results in lines drawn to the "opposite" position :-)

When I utilize XAxisKey, YAxiskey on LineSeries and Key on magnitude and angle then it is possible to you the sortedlist when binding to the key and value properties (DataFieldX and DataFieldY)

There was an exception (OxyPlot paint exception Angle Axis Should always be Y axis) - however the examples add the Angle Axis first.
Can you draw (in MS paint etc.) what's your goal?

Just to clarify...
The goal was initially just to get a polar plot to work. The samples use FunctionSeries hence I was a bit puzzled about the binding - my problems seems to relate to the Angle has to be the Y axis. Using all the Field and AxisKey makes it work.

The bug I have found is with using min and max values on the magnitude axis. I I wen't below min then a line was drawn crossing the center.
This may be a bit of misuse from my side - I should filter the data that are not sensible with my provided min and max values.
However other polar charts that I have worked with draws the approximated line to where the min would be - but it does not cross the center of the polar plot.