ScottPlot
ScottPlot copied to clipboard
SP5 Controls: right-click "Save As" should launch options dialog
Bug Report
Issue: SVG export produces blocky output for SignalPlot over a certain data density.
Reproducing: See code below. Amount of data needed to cause problem is probably proportional to size of the plot.
private double[] RandData(int count) {
double[] d = new double[count];
Random r = new Random();
for (int i = 0; i < count; i++) d[i] = r.NextDouble()*100;
return d;
}
private void Form1_Load(object sender, EventArgs e) {
double[] data2 = RandData(800);
Signal s2 = formsPlot1.Plot.Add.Signal(data2);
s2.LineStyle.Color = Colors.Blue;
s2.LineStyle.Width = 1;
s2.Data.YOffset = 100;
s2.Marker = MarkerStyle.None;
s2.Data.YOffset = 150;
}
System Details
- ScottPlot Version: 5.0.11-beta
- Operating System: Windows 10
- Application Type: WinForms
- .NET Version: .NET 8.0
Hi @raburton, thanks for reporting this!
Signal plots are fast because they do a trick: they draw a vertical line for each pixel column containing data.
In the case of the SVG output it doesn't look good because it's zoomed in so far. I think the solution here is to export the SVG at high resolution (e.g., 2000x1000) ... but I recognize there's no good way to do that from a FormsPlot via the right-click dialog, so I'll modify this issue to add a feature where users are prompted for the size of the SVG to export. This should fix the issue!
... it should also let the user decide whether or not to have a transparent or solid background color
Hi @raburton, thanks for reporting this!
Signal plots are fast because they do a trick: they draw a vertical line for each pixel column containing data.
I assume this is only the case for dense data? With less data points (600 or lower worked for me with the above example code) I don't get the simplified SVG, all the lines are as you'd expect (diagonal from data point to data point) and I can zoom right in as far as I want on the SVG and they still look good.
In the case of the SVG output it doesn't look good because it's zoomed in so far. I think the solution here is to export the SVG at high resolution (e.g., 2000x1000) ... but I recognize there's no good way to do that from a FormsPlot via the right-click dialog, so I'll modify this issue to add a feature where users are prompted for the size of the SVG to export. This should fix the issue!
I don't think in pixels for vectors graphics, so are you referring to an internal representation of the chart at the size (thus making the data less dense) so it draws properly? If so, whatever size you pick, this problem will still occur for denser data than that size allows for. Perhaps better to just draw the full data to the SVG, instead of using the simplified method for denser data.
Hi @raburton I'm still working on this but one brief note (writing from my phone)
If a signal plot has 1 billion points, a SVG with 1 billion lines will probably crash (and be a massive file size) so some data reduction must be done. Using a rule like "at most one line per pixel" is a reasonable compromise.
Note that scatter plots don't have this issue. If you save your data as a scatter plot the SVG will look good.
Signal plots work by taking "pixel column" shortcuts, so exporting SVGs will always involve some type of data reduction