Conversation
Hi @CoderPM2011, I took a quick look and this is looking great! Feel free to create whatever types and interfaces feel right, and I can refine them as needed right before I merge. Let me know when you think this is ready to merge and I'll make those edits and add it to the cookbook! 🚀 Note that the test are failing because the new classes in the |
If you'd rather, I can make some refinements myself by editing the code in this PR, then let you know when I'm done so you can pick it up again. I don't want to start making commits here without you being ready for it though, because merge conflicts inside pull requests can get pretty annoying 🤪 Take as long as you need! I'm putting a lot of time today into #3186 |
- convert degrees to radians - convert radians to degrees - normalize radians to [0, 2π] - normalize degrees to [0,360]
- angular unit use degrees - support for converting between polar and Cartesian coordinates
515d8af to
8c64f82
Compare
|
The test code is at the bottom. I'm not sure if the current axis naming is suitable or easily understandable. My test code: var pts = new PolarCoordinates[] {
new PolarCoordinates(10, 45),
new PolarCoordinates(50, 90),
new PolarCoordinates(30, 127),
new PolarCoordinates(15, 270),
new PolarCoordinates(125, 180),
};
ScottPlot.Plottables.Polar polar = formsPlot1.Plot.Add.Polar(pts);
ScottPlot.Color[] map = new ScottPlot.Colormaps.Turbo()
.GetColors(polar.CircularAxis.AxisLines.Length);
polar.RadialAxis.Spokes[1].LineStyle.Pattern = LinePattern.Dotted;
polar.RadialAxis.Spokes[1].LineStyle.Width = 3;
polar.RadialAxis.Spokes[1].LineStyle.Color = Colors.Red;
polar.RadialAxis.Spokes[2].LineStyle.Pattern = LinePattern.Dashed;
polar.RadialAxis.Spokes[2].LineStyle.Width = 2;
polar.RadialAxis.Spokes[2].LineStyle.Color = Colors.Silver;
polar.RadialAxis.Spokes[3].LineStyle.Pattern = LinePattern.DenselyDashed;
polar.RadialAxis.Spokes[3].LineStyle.Width = 5;
polar.RadialAxis.Spokes[3].LineStyle.Color = Colors.Purple;
for (int i = 0; i < polar.CircularAxis.AxisLines.Length - 1; i++)
{
polar.CircularAxis.AxisLines[i].LineStyle.Pattern =
(i % 2 == 0)
? LinePattern.Dotted
: LinePattern.DenselyDashed;
polar.CircularAxis.AxisLines[i].LineStyle.Width =
(i % 2 == 0)
? 3
: 1;
polar.CircularAxis.AxisLines[i].LineStyle.Color =
map[i].WithLightness(0.3F);
}
polar.LegendText = "TEST";
var RadialAxisPt = Coordinates.FromPolarCoordinates(130, 300);
for (int i = 0; i < 4; i++)
{
var RadialAxisPt2 = Coordinates.FromPolarCoordinates(70, 90 * i);
formsPlot1.Plot.Add.Callout(
"RadialAxis",
textLocation: RadialAxisPt.WithDelta(+50, 0),
tipLocation: RadialAxisPt2);
}
var CircularAxisPt = Coordinates.FromPolarCoordinates(125, 140);
for (int i = 1; i <= 4; i++)
{
var CircularAxisPt2 = Coordinates.FromPolarCoordinates(125.0 * i / 4.0, 140);
formsPlot1.Plot.Add.Callout(
"CircularAxis",
textLocation: CircularAxisPt.WithDelta(-150, 0),
tipLocation: CircularAxisPt2);
}
formsPlot1.Update(); |
|
Hi @CoderPM2011, thanks so much for this PR! It took me a while to get to because I was focused entirely on #4053 for the last few weeks, but now that it's merged I'm happy to pick this up now. I'll probably make a few refinements, then merge it just like it is. This is looking great! 🚀 |
|
Heads up, the two major change I'm about to start pushing to this branch are:
|
|
Still a work in progress, but you can probably see the direction this is going by looking at the new cookbook recipes! Thanks again for your work on this! It's looking fantastic! 🚀 |
|
Following-up, I removed some of the functionality from a few of the types that wasn't used (equality checks, implicit operations between polar coordinates and cartesian coordinates, etc.) but if you think it would be useful to other peoples' workflows (code outside ScottPlot) let me know and we can add some of that back in. Thanks again for this PR @CoderPM2011! It was a pleasure to review today 😄 I'm going to merge it now, but feel free to open new PRs if you recommend refinements and I'll merge those in quickly 🚀 |

This was originally designed for #3939, but later I decided to develop it into a polar coordinate-based plot because some plots are easier to implement in polar coordinates.
Due to the need to base it on polar coordinates, I have added a lot of related code.
However, I'm unsure whether some of the changes are necessary or appropriate.
The ultimate goal is to make this plot easier to implement,
similar to radar plots, pie plots, or other similar types of plots.
The Polar Plot now functions like a scatter plot on polar coordinates,
using Circular and Radial axes instead of standard X and Y axes.
My test code: