Miguel Moura
Miguel Moura

Reputation: 39474

Create Multiline Chart with Plotly

Using Net 6 and Plotly I have:

List<Int32> xValues = Enumerable.Range(1, 500);

List<Single> y1Values = getY1Values();

List<Single> y2Values = getY2Values();  

How to create one Plotly.Net C# chart with 2 lines (for y1Values and for y2Values)?

I was only able to create with one set of y values:

GenericChart.GenericChart chart = Chart2D.Chart.Line<Int32, Single, String>(xValues, y1Values);

Upvotes: 0

Views: 600

Answers (1)

Matthew Holmes
Matthew Holmes

Reputation: 802

Create a chart for each line plot. Add them to a list, then create a new chart using Chart.Combine

var chartY1 = Chart2D.Chart.Line<int, Single, string>(xValues, y1Values);
var chartY2 = Chart2D.Chart.Line<int, Single, string>(xValues, y2Values);

var chartList = new List<GenericChart.GenericChart>();
chartList.Add(chartY1);
chartList.Add(chartY2);

var combinedChart = Chart.Combine(list);

Upvotes: 1

Related Questions