ScottPlot is amazing – How to get settings.

I’ve recently found ScottPlot, and it’s amazing.

Most things are straight forward, and there’s plenty of recipes to try out to get the graphs to do what you want.

However, sometimes things aren’t as easy as you’d think.

No, I may or may not have gone about this the right or original way as the author intended, but, this will work.

If you have multiple plots on your graph and you need to know which is which, or index order and you know what the label is, then this should help you out.

formsPlot1.plt.PlotVLine(label: "green", lineWidth: 3, x: position, draggable: true, dragLimitLower: 0, dragLimitUpper: Global.samples[filename_value]);
String plotname = "";

int plottablescount = formsPlot1.plt.GetSettings(false).plottables.Count; 
for (int i = 0; i < plottablescount; i++)
Console.WriteLine(formsPlot1.plt.GetSettings(false).plottables[i].ToString());      //  PlottableVLine (green) at X=516587
Console.WriteLine(formsPlot1.plt.GetSettings(false).plottables[i].GetLegendItems());//  ScottPlot.Config.LegendItem[]
Console.WriteLine(formsPlot1.plt.GetSettings(false).plottables[i].GetLimits());     //  x1=516587.000, x2=516587.000, y1=NaN, y2=NaN
Console.WriteLine(formsPlot1.plt.GetSettings(false).plottables[i].GetType());       //  ScottPlot.PlottableVLine
Console.WriteLine(formsPlot1.plt.GetSettings(false).plottables[i].GetHashCode());   //  2383799
var stringlabel = formsPlot1.plt.GetSettings(false).plottables[i].ToString();       //  PlottableVLine (green) at X=516587
Console.WriteLine(Regex.Match(stringlabel, @"\(([^)]*)\)").Groups[1].Value); // This will extract the name of the moveable plotline

plotname = Regex.Match(stringlabel, @"\(([^)]*)\)").Groups[1].Value;

if (plotname == "green")
    // do stuff


It loops through the plots you have and then searches for the label you have given your plot, in my case, the label is called green.

Link to the gist

PS. I don’t know how anyone can use this new WordPress content editor. It’s just awful.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at

Up ↑

%d bloggers like this: