Skip to content

Scatter plot render artifacts #889

@grabul

Description

@grabul

If you have different densities on the x-axis of your scatter data and you zoom into a high density area there are render errors drawing additional horizontal lines where we shouldn't have there.
example code:

var plt = new ScottPlot.Plot(600, 400);
int pointCount = 1000;
double[] ys = new double[pointCount];
double[] xs = new double[pointCount];
double currentX = 0;
 for (int i = 0; i < pointCount; i++)
 {
    if ((i % 100) < 10)
       currentX += 10;
    else
       currentX += 0.001;
    xs[i] = currentX;
    ys[i] = i % 2 == 0 ? 1.0 : 0.0;
 }
plt.AddScatterStep(xs, ys);

Also belongs to a normal ScatterPlot (no step style) where you add additional data points to create the steps "by hand" within the loop like:

var plt = new ScottPlot.Plot(600, 400);
int pointCount = 1000;
var xs = new List<double>();
var ys = new List<double>();
double last_y = -1.0;
double currentX = 0;
for (int i = 0; i < pointCount; i++)
{
  if ((i % 100) < 10)
     currentX += 10;
  else
     currentX += 0.001;

  if (last_y >= 0.0)
  {
     xs.Add(currentX);
     ys.Add(last_y);
  }

  xs.Add(currentX);
  last_y = i % 2 == 0 ? 1.0 : 0.0;
  ys.Add(last_y);
}
plt.AddScatter(xs.ToArray(), ys.ToArray());

scatter

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGunexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions