XPlot


Plotly 2D Histograms

Full source and data

2D Histogram of a Bivariate Normal Distribution

1: 
2: 
3: 
4: 
5: 
6: 
7: 
Histogram2d(
    x = x,
    y = y
)
|> Chart.Plot
|> Chart.WithWidth 700
|> Chart.WithHeight 500

2D Histogram Binning and Styling Options

 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: 
Histogram2d(
    x = x,
    y = y,
    histnorm = "probability",
    autobinx = false,
    xbins =
        Xbins(
            start = -3.,
            ``end`` = 3.,
            size = 0.1
        ),
    autobiny = false,
    ybins =
        Ybins(
            start = -2.5,
            ``end`` = 4.,
            size = 0.1
        ),
    colorscale =
        [
            [box 0; box "rgb(12,51,131)"]
            [0.25; "rgb(10,136,186)"]
            [0.5; "rgb(242,211,56)"]
            [0.75; "rgb(242,143,56)"]
            [1; "rgb(217,30,30)"]
        ]
)
|> Chart.Plot
|> Chart.WithWidth 700
|> Chart.WithHeight 500

2D Histogram Overlaid with a Scatter 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: 
let trace1 =
    Scatter(
        x = x0,
        y = y0,
        mode = "markers",
        marker =
            Marker(
                symbol = "circle",
                opacity = 0.7
            )
    )

let trace2 =
    Scatter(
        x = x1,
        y = y1,
        mode = "markers",
        marker =
            Marker(
                symbol = "square",
                opacity = 0.7
            )
    )

let trace3 =
    Histogram2d(
        x = x',
        y = y'
    )

let layout = Layout(showlegend = false)

[trace1 :> Trace; trace2 :> _; trace3 :> _]
|> Chart.Plot
|> Chart.WithWidth 700
|> Chart.WithHeight 500
|> Chart.WithLayout layout
Fork me on GitHub