Hi, I am looking for help improving the speed of this chart type.
Here is my best attempt at a standalone example:
```
import numpy as np
import plotly.graph_objects as go
# 13 ranks in poker order
ranks = list("AKQJT98765432")
# generate a random 3-way action split for each hand: F + C + R = 1
rng = np.random.default_rng(42)
F = np.zeros((13, 13), dtype=float)
C = np.zeros((13, 13), dtype=float)
R = np.zeros((13, 13), dtype=float)
for i in range(13):
for j in range(13):
probs = rng.dirichlet(np.array([1.5, 1.5, 1.5]))
F[i, j], C[i, j], R[i, j] = probs
# make the matrix symmetric so it behaves like a range matrix
for i in range(13):
for j in range(i, 13):
F[j, i] = F[i, j]
C[j, i] = C[i, j]
R[j, i] = R[i, j]
# Colors roughly matching the app: blue=fold, green=call, red=raise
COLORS = {
"F": "#b7d7ef",
"C": "#9ad7a6",
"R": "#f08e8e",
}
fig = go.Figure()
cell_w = 1.0
cell_h = 1.0
for i in range(13):
for j in range(13):
x0 = j
x1 = j + cell_w
y0 = i
y1 = i + cell_h
# stack in the same visual order as the app: R at the bottom, C middle, F top
r_h = R[i, j]
c_h = C[i, j]
f_h = F[i, j]
# bottom slice: raise
y_bottom = y0
y_top = y0 + r_h * cell_h
fig.add_shape(
type="rect",
x0=x0,
x1=x1,
y0=y_bottom,
y1=y_top,
fillcolor=COLORS["R"],
line=dict(color="rgba(0,0,0,0)", width=0),
opacity=0.95,
)
# middle slice: call
y_bottom = y0 + r_h * cell_h
y_top = y0 + (r_h + c_h) * cell_h
fig.add_shape(
type="rect",
x0=x0,
x1=x1,
y0=y_bottom,
y1=y_top,
fillcolor=COLORS["C"],
line=dict(color="rgba(0,0,0,0)", width=0),
opacity=0.95,
)
# top slice: fold
y_bottom = y0 + (r_h + c_h) * cell_h
y_top = y0 + cell_h
fig.add_shape(
type="rect",
x0=x0,
x1=x1,
y0=y_bottom,
y1=y_top,
fillcolor=COLORS["F"],
line=dict(color="rgba(0,0,0,0)", width=0),
opacity=0.95,
)
# use a simple matrix layout to mimic the screenshot
fig.update_xaxes(
range=[0, 13],
tickmode="array",
tickvals=np.arange(13) + 0.5,
ticktext=ranks,
showgrid=False,
zeroline=False,
side="top",
)
fig.update_yaxes(
range=[13, 0],
tickmode="array",
tickvals=np.arange(13) + 0.5,
ticktext=ranks,
showgrid=False,
zeroline=False,
autorange=False,
)
fig.update_layout(
title="SB action split",
width=1200,
height=1200,
margin=dict(l=40, r=40, t=60, b=40),
template="plotly_white",
showlegend=False,
paper_bgcolor="white",
plot_bgcolor="white",
)
fig.show()

