Bar Charts in Csharp
How to make Bar Charts in C# with Plotly.
In [1]:
#r "nuget: Plotly.NET, 2.0.0-preview.8"
#r "nuget: Plotly.NET.Interactive, 2.0.0-preview.8"
using Plotly.NET;
Basic Bar Chart¶
you can use C# arrays to construct your bar charts
In [2]:
var animals = new [] {"giraffes", "orangutans", "monkeys"};
var sfValues = new [] {20, 14, 23};
Chart2D.Chart.Column<string, int, string>(animals, sfValues)
Out[2]:
Grouped Bar Chart¶
Chart.combine for grouping the charts
In [3]:
var animals = new [] {"giraffes", "orangutans", "monkeys"};
var sfValues = new [] {20, 14, 23};
var laValues = new [] {12, 18, 29};
Chart.Combine(new [] {
Chart2D.Chart.Column<string, int, string>(animals, sfValues,"SF Zoo"),
Chart2D.Chart.Column<string, int, string>(animals, laValues, "LA Zoo")
})
Out[3]:
Stacked Bar Chart¶
Chart.StackedColumn for constructing stacked bars as shown below
In [4]:
var animals = new [] {"giraffes", "orangutans", "monkeys"};
var sfValues = new [] {20, 14, 23};
var laValues = new [] {12, 18, 29};
Chart.Combine(new []
{
Chart2D.Chart.StackedColumn<string, int, string>(animals, sfValues, "SF Zoo"),
Chart2D.Chart.StackedColumn<string, int, string>(animals, laValues, "LA Zoo")
})
Out[4]: