XPlot


Plotly Bar Charts

Basic Bar Chart

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
let basicData =
    Data(
        [
            Bar(
                x = ["giraffes"; "orangutans"; "monkeys"],
                y = [20; 14; 23]
            )
        ]
    )

Figure(basicData)

Grouped Bar Chart

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
let groupedTrace1 =
    Bar(
        x = ["giraffes"; "orangutans"; "monkeys"],
        y = [20; 14; 23],
        name= "SF Zoo"            
    )

let groupedTrace2 =
    Bar(
        x = ["giraffes"; "orangutans"; "monkeys"],
        y = [12; 18; 29],
        name = "LA Zoo"
    )

let data2 = Data [groupedTrace1; groupedTrace2]

let groupedLayout = Layout(barmode = "group")

Figure(data2, groupedLayout)

Stacked Bar Chart

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
let stackedTrace1 =
    Bar(
        x = ["giraffes"; "orangutans"; "monkeys"],
        y = [20; 14; 23],
        name = "SF Zoo"
    )

let stackedTrace2 =
    Bar(
        x= ["giraffes"; "orangutans"; "monkeys"],
        y= [12; 18; 29],
        name = "LA Zoo"
    )

let stackedData = Data [stackedTrace1; stackedTrace2]

let stackedLayout = Layout(barmode = "stack")
    
Figure(stackedData, stackedLayout)

Colored and Styled Bar Chart

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
54: 
55: 
56: 
57: 
58: 
59: 
60: 
61: 
62: 
63: 
64: 
let styledTrace1 =
    Bar(
        x =
            [1995; 1996; 1997; 1998; 1999; 2000; 2001; 2002; 2003; 2004; 2005; 2006;
             2007; 2008; 2009; 2010; 2011; 2012],
        y =
            [219; 146; 112; 127; 124; 180; 236; 207; 236; 263; 350; 430; 474; 526; 488;
            537; 500; 439],
        name = "Rest of world",
        marker = Marker(color = "rgb(55, 83, 109)")
    )

let styledTrace2 =
    Bar(
        x =
            [1995; 1996; 1997; 1998; 1999; 2000; 2001; 2002; 2003; 2004; 2005; 2006;
            2007; 2008; 2009; 2010; 2011; 2012],
        y =
            [16; 13; 10; 11; 28; 37; 43; 55; 56; 88; 105; 156; 270; 299; 340; 403; 549;
            499],        
        name = "China",
        marker = Marker(color = "rgb(26, 118, 255)")
    )

let styledData = Data [styledTrace1; styledTrace2]

let styledLayout =
    Layout(
        title = "US Export of Plastic Scrap",
        xaxis =
            XAxis(
                tickfont =
                    Font(
                        size = 14.,
                        color = "rgb(107, 107, 107)"
                    )
            ),
        yaxis =
            YAxis(
                title = "USD (millions)",
                titlefont =
                    Font(
                        size = 16.,
                        color = "rgb(107, 107, 107)"
                    ),
                tickfont =
                    Font(
                        size = 14.,
                        color = "rgb(107, 107, 107)"
                    )
            ),
        legend =
            Legend(
                x = 0.,
                y = 1.0,
                bgcolor = "rgba(255, 255, 255, 0)",
                bordercolor = "rgba(255, 255, 255, 0)"
            ),
        barmode = "group",
        bargap = 0.15,
        bargroupgap = 0.1
    )

Figure(styledData, styledLayout)

Bar Chart with Hover Text

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
let hoverTrace =
    Bar(
        x = ["Liam"; "Sophie"; "Jacob"; "Mia"; "William"; "Olivia"],
        y = [8.0; 8.0; 12.0; 12.0; 13.0; 20.0],
        text =
            ["4.17 below the mean"; "4.17 below the mean"; "0.17 below the mean";
            "0.17 below the mean"; "0.83 above the mean"; "7.83 above the mean"],
        marker = Marker(color = "rgb(142, 124, 195)")
    )

let hoverData = Data [hoverTrace]

let hoverLayout =
    Layout(
        title = "Number of graphs made this week",
        font = Font(family = "Raleway, sans-serif"),
        showlegend = false,
        xaxis= XAxis(tickangle = -45.),
        yaxis=
            YAxis(
                zeroline = false,
                gridwidth = 2.
            ),
        bargap = 0.05
    )

Figure(hoverData, hoverLayout)

Customizing Individual Bar Colors

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
let customData =
    Data(
        [
            Bar(
                x = [1; 2; 3; 4],
                y = [5; 4; -3; 2],
                marker = Marker(color = ["#447adb"; "#447adb"; "#db5a44"; "#447adb"])
            )
        ]
    )

Figure(customData)
namespace XPlot
namespace XPlot.Plotly
type Plotly =
  private new : unit -> Plotly
  static member Signin : username:string * password:string -> unit

Full name: XPlot.Plotly.Plotly
static member Plotly.Signin : username:string * password:string -> unit
module MyCredentials
val userAndKey : string * string

Full name: MyCredentials.userAndKey
val basicData : Data

Full name: Plotly-bar-charts.basicData
Multiple items
namespace Microsoft.FSharp.Data

--------------------
type Data =
  new : traces:seq<Trace> -> Data
  member Json : string
  static member From : traces:seq<#Trace> -> Data

Full name: XPlot.Plotly.Data

--------------------
new : traces:seq<Trace> -> Data
Multiple items
type Bar =
  inherit Trace
  new : unit -> Bar
  member ShouldSerializeerror_x : unit -> bool
  member ShouldSerializeerror_y : unit -> bool
  member ShouldSerializemarker : unit -> bool
  member ShouldSerializename : unit -> bool
  member ShouldSerializeopacity : unit -> bool
  member ShouldSerializeorientation : unit -> bool
  member ShouldSerializer : unit -> bool
  member ShouldSerializeshowlegend : unit -> bool
  ...

Full name: XPlot.Plotly.Graph.Bar

--------------------
new : unit -> Bar
property Bar.x: obj
property Bar.y: obj
Multiple items
type Figure =
  new : data:Data * ?Layout:Layout -> Figure
  member GetInlineHtml : filename:string -> string
  member Plot : filename:string -> PlotlyResponse option
  member Fileopt : string
  member Height : int
  member Layout : Layout option
  member Origin : string
  member Response : PlotlyResponse option
  member Width : int
  member Fileopt : string with set
  ...

Full name: XPlot.Plotly.Figure

--------------------
new : data:Data * ?Layout:Layout -> Figure
val groupedTrace1 : Bar

Full name: Plotly-bar-charts.groupedTrace1
val groupedTrace2 : Bar

Full name: Plotly-bar-charts.groupedTrace2
val data2 : Data

Full name: Plotly-bar-charts.data2
val groupedLayout : Layout

Full name: Plotly-bar-charts.groupedLayout
Multiple items
type Layout =
  new : unit -> Layout
  member ShouldSerializeangularaxis : unit -> bool
  member ShouldSerializeannotations : unit -> bool
  member ShouldSerializeautosize : unit -> bool
  member ShouldSerializebargap : unit -> bool
  member ShouldSerializebargroupgap : unit -> bool
  member ShouldSerializebarmode : unit -> bool
  member ShouldSerializebarnorm : unit -> bool
  member ShouldSerializeboxgap : unit -> bool
  member ShouldSerializeboxgroupgap : unit -> bool
  ...

Full name: XPlot.Plotly.Graph.Layout

--------------------
new : unit -> Layout
val stackedTrace1 : Bar

Full name: Plotly-bar-charts.stackedTrace1
val stackedTrace2 : Bar

Full name: Plotly-bar-charts.stackedTrace2
val stackedData : Data

Full name: Plotly-bar-charts.stackedData
val stackedLayout : Layout

Full name: Plotly-bar-charts.stackedLayout
val styledTrace1 : Bar

Full name: Plotly-bar-charts.styledTrace1
Multiple items
type Marker =
  new : unit -> Marker
  member ShouldSerializecauto : unit -> bool
  member ShouldSerializecmax : unit -> bool
  member ShouldSerializecmin : unit -> bool
  member ShouldSerializecolor : unit -> bool
  member ShouldSerializecolorscale : unit -> bool
  member ShouldSerializeline : unit -> bool
  member ShouldSerializemaxdisplayed : unit -> bool
  member ShouldSerializeopacity : unit -> bool
  member ShouldSerializeoutliercolor : unit -> bool
  ...

Full name: XPlot.Plotly.Graph.Marker

--------------------
new : unit -> Marker
val styledTrace2 : Bar

Full name: Plotly-bar-charts.styledTrace2
val styledData : Data

Full name: Plotly-bar-charts.styledData
val styledLayout : Layout

Full name: Plotly-bar-charts.styledLayout
Multiple items
type XAxis =
  new : unit -> XAxis
  member ShouldSerializeanchor : unit -> bool
  member ShouldSerializeautorange : unit -> bool
  member ShouldSerializeautotick : unit -> bool
  member ShouldSerializebackgroundcolor : unit -> bool
  member ShouldSerializedomain : unit -> bool
  member ShouldSerializedtick : unit -> bool
  member ShouldSerializeexponentformat : unit -> bool
  member ShouldSerializegridcolor : unit -> bool
  member ShouldSerializegridwidth : unit -> bool
  ...

Full name: XPlot.Plotly.Graph.XAxis

--------------------
new : unit -> XAxis
Multiple items
type Font =
  new : unit -> Font
  member ShouldSerializecolor : unit -> bool
  member ShouldSerializefamily : unit -> bool
  member ShouldSerializeoutlinecolor : unit -> bool
  member ShouldSerializesize : unit -> bool
  member color : string
  member family : string
  member outlinecolor : string
  member size : float
  member color : string with set
  ...

Full name: XPlot.Plotly.Graph.Font

--------------------
new : unit -> Font
Multiple items
type YAxis =
  new : unit -> YAxis
  member ShouldSerializeanchor : unit -> bool
  member ShouldSerializeautorange : unit -> bool
  member ShouldSerializeautotick : unit -> bool
  member ShouldSerializebackgroundcolor : unit -> bool
  member ShouldSerializedomain : unit -> bool
  member ShouldSerializedtick : unit -> bool
  member ShouldSerializeexponentformat : unit -> bool
  member ShouldSerializegridcolor : unit -> bool
  member ShouldSerializegridwidth : unit -> bool
  ...

Full name: XPlot.Plotly.Graph.YAxis

--------------------
new : unit -> YAxis
Multiple items
type Legend =
  new : unit -> Legend
  member ShouldSerializebgcolor : unit -> bool
  member ShouldSerializebordercolor : unit -> bool
  member ShouldSerializeborderwidth : unit -> bool
  member ShouldSerializefont : unit -> bool
  member ShouldSerializetraceorder : unit -> bool
  member ShouldSerializex : unit -> bool
  member ShouldSerializexanchor : unit -> bool
  member ShouldSerializexref : unit -> bool
  member ShouldSerializey : unit -> bool
  ...

Full name: XPlot.Plotly.Graph.Legend

--------------------
new : unit -> Legend
property Legend.x: float
property Legend.y: float
val hoverTrace : Bar

Full name: Plotly-bar-charts.hoverTrace
val hoverData : Data

Full name: Plotly-bar-charts.hoverData
val hoverLayout : Layout

Full name: Plotly-bar-charts.hoverLayout
val customData : Data

Full name: Plotly-bar-charts.customData
Fork me on GitHub