ScottPlot/ScottPlot

Scatter plot with fill doesn't clip line

BendRocks opened this issue · 2 comments

Issue: (Describe the bug here)
When FillY is enabled with a scatter plot, the trace lines are not correctly clipped.

ScottPlot Version: (What NuGet package are you using?)

5.0.34.0

I cloned the repo and modified the Sandbox.Winforms.Form1.cs

Code Sample: See http://scottplot.net/faq/repro/ for tips about creating reproducible code samples

The following code was put into the Form1 constructor in the Sandbox.Winforms

  double[] xs = { 1, 10, 100, 1000, 10_000, 100_000 };
  double[] ys = { -50, -50, 10, -50, -80, -80 };

  // add log-scaled data to the plot
  ScottPlot.Plottables.Scatter sp = formsPlot1.Plot.Add.Scatter(xs, ys);
  sp.LineWidth = 5;
  sp.FillY = false;
  sp.FillYValue = -200;
 
  formsPlot1.Plot.Axes.Bottom.Min = 100;
  formsPlot1.Plot.Axes.Bottom.Max = 10000;

The output is as expected, with the trace clipped at the left and right edges of the plot:

image

If the same code is used, with sp.FillY set to true, we see the following output:

image

Notice above that the lines are no longer clipped at the left and right. Note the different shading of the fill is due to the bug #3791. That same block of code in scatter.cs code is likely the culprit since the lines render correctly when FillY is false.