在 WPF ScottPlot 中隐藏情节

Hide plot in WPF ScottPlot

让我们看最基本的代码:

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" />

它将在一张图表上生成两个图。

而且我不知道如何隐藏特定情节,例如第一个。这里似乎没有开箱即用的功能,所以你必须自己添加一些按钮,但我什至找不到任何隐藏它的功能。文档中的零信息。

您想使用 IsVisible 字段。它列在这里:https://swharden.com/scottplot/cookbooks/4.1.13-beta/api/plottable/scatterplot/#isvisible

文档不存在,但 IsVisible 就是您认为的那样。

你的代码变成这样:

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