XPlot


Plotly Histograms

Full source and data

Basic Histogram

1: 
2: 
3: 
4: 
Histogram(x = basicX)
|> Chart.Plot
|> Chart.WithWidth 700
|> Chart.WithHeight 500

Horizontal Histogram

1: 
2: 
3: 
4: 
5: 
6: 
7: 
let horizontalLayout = Layout(title = "Horizontal Histogram")
       
Histogram(y = horizontalY)
|> Chart.Plot
|> Chart.WithLayout horizontalLayout
|> Chart.WithWidth 700
|> Chart.WithHeight 500

Overlaid Histogram

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
let overlaidTrace1 =
    Histogram(
        x = overlaidX0,
        opacity = 0.75
    )

let overlaidTrace2 =
    Histogram(
        x = overlaidX1,
        opacity = 0.75
    )

let overlaidLayout =
    Layout(
        barmode = "overlay",
        title = "Overlaid Histogram"
    )

[overlaidTrace1; overlaidTrace2]
|> Chart.Plot
|> Chart.WithLayout overlaidLayout
|> Chart.WithWidth 700
|> Chart.WithHeight 500

Stacked Histograms

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
let stackedTrace1 = Histogram(x = stackedX0)

let stackedTrace2 = Histogram(x = stackedX1)

let stackedLayout =
    Layout(
        barmode = "stack",
        title = "Stacked Histograms"
    )

[stackedTrace1; stackedTrace2]
|> Chart.Plot
|> Chart.WithLayout stackedLayout
|> Chart.WithWidth 700
|> Chart.WithHeight 500

Colored and Styled Histograms

 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: 
let coloredTrace1 =
    Histogram(
        x = coloredX0,
        histnorm = "count",
        name = "control",
        autobinx = false,
        xbins =
            Xbins(
                start = -3.2,
                ``end`` = 2.8,
                size = 0.2
            ),
        marker =
            Marker(
                color = "fuchsia",
                line =
                    Line(
                        color = "grey",
                        width = 0
                    ),
                opacity = 0.75
            )
    )

let coloredTrace2 =
    Histogram(
        x = coloredX1,
        name = "experimental",
        autobinx = false,
        xbins =
            Xbins(
                start = -1.8,
                ``end`` = 4.2,
                size = 0.2
            ),
        marker = Marker(color = "rgb(255, 217, 102)"),
        opacity = 0.75
    )

let coloredLayout =
    Layout(
        title = "Colored and Styled Histograms",
        xaxis = Xaxis(title = "Value"),
        yaxis = Yaxis(title = "Count"),
        barmode = "overlay",
        bargap = 0.25,
        bargroupgap = 0.3
    )

[coloredTrace1; coloredTrace2]
|> Chart.Plot
|> Chart.WithLayout coloredLayout
|> Chart.WithWidth 700
|> Chart.WithHeight 500
Fork me on GitHub