// can't yet format YamlFrontmatter (["title: Bar and column charts"; "category: Simple Charts"; "categoryindex: 3"; "index: 2"], Some { StartLine = 2 StartColumn = 0 EndLine = 6 EndColumn = 8 }) to pynb markdown

In [ ]:
#r "nuget: Plotly.NET, 2.0.0-preview.16"
#r "nuget: Plotly.NET.Interactive, 2.0.0-preview.16"


# Bar and column charts¶

Summary: This example shows how to create bar and a column charts in F#.

let's first create some data for the purpose of creating example charts:

In [3]:
open Plotly.NET

let values = [20; 14; 23;]
let keys   = ["Product A"; "Product B"; "Product C";]


A bar chart or bar graph is a chart that presents grouped data with rectangular bars with lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally. A vertical bar chart is called a column bar chart.

### Column Charts¶

In [4]:
let column = Chart.Column(values,keys)

In [ ]:
column

Out[ ]:

### Bar Charts¶

In [6]:
let bar =
Chart.Bar(values,keys)

In [ ]:
bar

Out[ ]:

## Stacked bar chart or column charts¶

The following example shows how to create a stacked bar chart by combining bar charts created by combining multiple Chart.StackedBar charts:

Basically those charts are just normal bar/column charts with the Layout property BarMode set to Stack. You can do this yourself by changing the Chart layout.

### Stacked bar Charts¶

In [8]:
let stackedBar =
[
Chart.StackedBar(values,keys,Name="old");
Chart.StackedBar([8; 21; 13;],keys,Name="new")
]
|> Chart.combine

In [ ]:
stackedBar

Out[ ]:
In [10]:
(*
### Stacked bar Charts
*)

let stackedColumn =
[
Chart.StackedColumn(values,keys,Name="old");
Chart.StackedColumn([8; 21; 13;],keys,Name="new")
]
|> Chart.combine

In [ ]:
stackedColumn

Out[ ]: