Hide plot in WPF ScottPlot

1.4k views Asked by At

Lets take the most basic code:

int pointCount = 10000;
double[] x = DataGen.Consecutive(pointCount);
double[] sin = DataGen.Sin(pointCount);
double[] cos = DataGen.Cos(pointCount);

WpfPlot1.Plot.AddScatter(x, sin);
WpfPlot1.Plot.AddScatter(x, cos);
<WpfPlot Name="WpfPlot1" />

It will generate two plots on one chart.

And I can't figure out how to hide specific plot, for example first one. It seems there is no out of the box functionality here, so you have to add some buttons yourself, but I can't even find any function that hides it. Zero info inside documentation.

1

There are 1 answers

0
Ben On BEST ANSWER

You want to use the IsVisible field. It is listed here: https://swharden.com/scottplot/cookbooks/4.1.13-beta/api/plottable/scatterplot/#isvisible

The documentation isn't there, but IsVisible is what you think it is.

Your code becomes this:

int pointCount = 10000;
double[] x = DataGen.Consecutive(pointCount);
double[] sin = DataGen.Sin(pointCount);
double[] cos = DataGen.Cos(pointCount);

var plot1 = WpfPlot1.Plot.AddScatter(x, sin);
var plot2 = WpfPlot1.Plot.AddScatter(x, cos);

plot1.IsVisible = false; // Hide plot1
plot1.IsVisible = true; // Show plot1