Bar and column charts

BinderScriptNotebook

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:

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

let column = Chart.Column(values,keys)

Bar Charts

let bar =
    Chart.Bar(values,keys)

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:

Stacked bar Charts

let stackedBar =
    [
        Chart.StackedBar(values,keys,Name="old");
        Chart.StackedBar([8; 21; 13;],keys,Name="new")
    ]
    |> Chart.combine
(*
### Stacked bar Charts
*)

let stackedColumn =
    [
        Chart.StackedColumn(values,keys,Name="old");
        Chart.StackedColumn([8; 21; 13;],keys,Name="new")
    ]
    |> Chart.combine
namespace Plotly
namespace Plotly.NET
val values : int list
val keys : string list
val column : GenericChart.GenericChart
type Chart = static member Area : x:seq<#IConvertible> * y:seq<#IConvertible> * ?Name:string * ?ShowMarkers:bool * ?ShowLegend:bool * ?MarkerSymbol:MarkerSymbol * ?Color:Color * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:DrawingStyle * ?Width:float -> GenericChart + 1 overload static member Bar : values:seq<#IConvertible> * ?Keys:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:PatternShape * ?MultiPatternShape:seq<PatternShape> * ?Pattern:Pattern * ?Base:#IConvertible * ?Width:'d * ?MultiWidth:seq<'d> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'e * ?MultiText:seq<'e> * ?TextPosition:TextPosition * ?MultiTextPosition:seq<TextPosition> * ?TextFont:Font * ?Marker:Marker -> GenericChart (requires 'd :> IConvertible and 'e :> IConvertible) + 1 overload static member BoxPlot : ?x:'a0 * ?y:'a1 * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?Fillcolor:Color * ?Opacity:float * ?Whiskerwidth:'a2 * ?Boxpoints:Boxpoints * ?Boxmean:BoxMean * ?Jitter:'a3 * ?Pointpos:'a4 * ?Orientation:Orientation * ?Marker:Marker * ?Line:Line * ?Alignmentgroup:'a5 * ?Offsetgroup:'a6 * ?Notched:bool * ?NotchWidth:float * ?QuartileMethod:QuartileMethod -> GenericChart + 1 overload static member Bubble : x:seq<#IConvertible> * y:seq<#IConvertible> * sizes:seq<int> * ?Name:string * ?ShowLegend:bool * ?MarkerSymbol:MarkerSymbol * ?Color:Color * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart + 1 overload static member Candlestick : open:seq<#IConvertible> * high:seq<#IConvertible> * low:seq<#IConvertible> * close:seq<#IConvertible> * x:seq<#IConvertible> * ?Increasing:Line * ?Decreasing:Line * ?WhiskerWidth:float * ?Line:Line * ?XCalendar:Calendar -> GenericChart + 1 overload static member Column : values:seq<#IConvertible> * ?Keys:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?Pattern:Pattern * ?PatternShape:PatternShape * ?MultiPatternShape:seq<PatternShape> * ?Base:#IConvertible * ?Width:'d * ?MultiWidth:seq<'d> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'e * ?MultiText:seq<'e> * ?TextPosition:TextPosition * ?MultiTextPosition:seq<TextPosition> * ?TextFont:Font * ?Marker:Marker -> GenericChart (requires 'd :> IConvertible and 'e :> IConvertible) + 1 overload static member Contour : data:seq<#seq<'a1>> * ?X:seq<#IConvertible> * ?Y:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Colorscale:Colorscale * ?Showscale:'a4 * ?zSmooth:SmoothAlg * ?ColorBar:'a5 -> GenericChart (requires 'a1 :> IConvertible) static member Funnel : x:seq<#IConvertible> * y:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Color:Color * ?Line:Line * ?x0:'a3 * ?dX:float * ?y0:'a4 * ?dY:float * ?Width:float * ?Offset:float * ?Orientation:Orientation * ?Alignmentgroup:string * ?Offsetgroup:string * ?Cliponaxis:bool * ?Connector:FunnelConnector * ?Insidetextfont:Font * ?Outsidetextfont:Font -> GenericChart static member Heatmap : data:seq<#seq<'a1>> * ?ColNames:seq<#IConvertible> * ?RowNames:seq<#IConvertible> * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Colorscale:Colorscale * ?Showscale:'a4 * ?Xgap:'a5 * ?Ygap:'a6 * ?zSmooth:SmoothAlg * ?ColorBar:'a7 * ?UseWebGL:bool -> GenericChart (requires 'a1 :> IConvertible) static member Histogram : data:seq<#IConvertible> * ?Orientation:Orientation * ?Name:string * ?ShowLegend:bool * ?Opacity:float * ?Color:Color * ?HistNorm:HistNorm * ?HistFunc:HistFunc * ?nBinsx:int * ?nBinsy:int * ?Xbins:Bins * ?Ybins:Bins * ?xError:'a1 * ?yError:'a2 -> GenericChart ...
static member Chart.Column : keysValues:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Pattern:TraceObjects.Pattern * ?Base:#System.IConvertible * ?Width:'a3 * ?MultiWidth:seq<'a3> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'a4 * ?MultiText:seq<'a4> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'a3 :> System.IConvertible and 'a4 :> System.IConvertible)
static member Chart.Column : values:seq<#System.IConvertible> * ?Keys:seq<#System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?Pattern:TraceObjects.Pattern * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Base:#System.IConvertible * ?Width:'d * ?MultiWidth:seq<'d> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'e * ?MultiText:seq<'e> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'd :> System.IConvertible and 'e :> System.IConvertible)
module GenericChart from Plotly.NET
<summary> Module to represent a GenericChart </summary>
val toChartHTML : gChart:GenericChart.GenericChart -> string
<summary> Converts a GenericChart to it HTML representation. The div layer has a default size of 600 if not specified otherwise. </summary>
val bar : GenericChart.GenericChart
static member Chart.Bar : keysValues:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Pattern:TraceObjects.Pattern * ?Base:#System.IConvertible * ?Width:'a3 * ?MultiWidth:seq<'a3> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'a4 * ?MultiText:seq<'a4> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'a3 :> System.IConvertible and 'a4 :> System.IConvertible)
static member Chart.Bar : values:seq<#System.IConvertible> * ?Keys:seq<#System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Pattern:TraceObjects.Pattern * ?Base:#System.IConvertible * ?Width:'d * ?MultiWidth:seq<'d> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'e * ?MultiText:seq<'e> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'd :> System.IConvertible and 'e :> System.IConvertible)
val stackedBar : GenericChart.GenericChart
static member Chart.StackedBar : keysValues:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Pattern:TraceObjects.Pattern * ?Base:#System.IConvertible * ?Width:'a3 * ?MultiWidth:seq<'a3> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'a4 * ?MultiText:seq<'a4> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'a3 :> System.IConvertible and 'a4 :> System.IConvertible)
static member Chart.StackedBar : values:seq<#System.IConvertible> * ?Keys:seq<#System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Pattern:TraceObjects.Pattern * ?Base:#System.IConvertible * ?Width:'d * ?MultiWidth:seq<'d> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'e * ?MultiText:seq<'e> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'd :> System.IConvertible and 'e :> System.IConvertible)
static member Chart.combine : gCharts:seq<GenericChart.GenericChart> -> GenericChart.GenericChart
val stackedColumn : GenericChart.GenericChart
static member Chart.StackedColumn : keysValues:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?Pattern:TraceObjects.Pattern * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Base:#System.IConvertible * ?Width:'a3 * ?MultiWidth:seq<'a3> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'a4 * ?MultiText:seq<'a4> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'a3 :> System.IConvertible and 'a4 :> System.IConvertible)
static member Chart.StackedColumn : values:seq<#System.IConvertible> * ?Keys:seq<#System.IConvertible> * ?Name:string * ?ShowLegend:bool * ?Color:Color * ?PatternShape:StyleParam.PatternShape * ?MultiPatternShape:seq<StyleParam.PatternShape> * ?Pattern:TraceObjects.Pattern * ?Base:#System.IConvertible * ?Width:'d * ?MultiWidth:seq<'d> * ?Opacity:float * ?MultiOpacity:seq<float> * ?Text:'e * ?MultiText:seq<'e> * ?TextPosition:StyleParam.TextPosition * ?MultiTextPosition:seq<StyleParam.TextPosition> * ?TextFont:Font * ?Marker:TraceObjects.Marker -> GenericChart.GenericChart (requires 'd :> System.IConvertible and 'e :> System.IConvertible)