import plotly.express as px
from plotly.graph_objects import Figure, Scatter

COLS: int = 3
fig: Figure = px.colors.sequential.swatches_continuous()
fig3: Figure = px.colors.qualitative.swatches()
figb: Figure = px.colors.sequential.swatches()

fig2 = Figure(layout={
    "title": "Palette de couleurs continues Plotly Sequential",
    "font": {"family": "Cabin", "size": 13},
    "xaxis": {"visible": False, "showticklabels": False},
    "yaxis": {"visible": False, "showticklabels": False},
    "legend": {"visible": False},
    "width": 1400,
}).set_subplots(rows=22, cols=COLS)
for i, p in enumerate(fig.select_traces()):  #type: int, Scatter
    fig2.add_trace(p, row= (i // COLS) + 1, col=(i % COLS) + 1)
fig2.update_xaxes({"visible": False, "showticklabels": False, "showgrid": False})
fig2.update_yaxes({"visible": True, "showticklabels": True, "showgrid": False})
fig2.update_yaxes(tickfont={"size": 11}, ticksuffix="   ")
fig2.write_image("eda-plotly-colors-continuous.svg")
# fig2.show(renderer="browser")

fig4 = Figure(layout={
    "title": "Palette de couleurs séquentielles Plotly Sequential",
    "font": {"family": "Cabin", "size": 13},
    "xaxis": {"visible": False, "showticklabels": False},
    "yaxis": {"visible": False, "showticklabels": False},
    "legend": {"visible": False},
    "width": 1400,
    "margin": {"t": 100, "b": 50, "l": 60, "r": 50},
}).set_subplots(rows=22, cols=COLS)
for i, p in enumerate(figb.select_traces()):  #type: int, Scatter
    fig4.add_trace(p, row= (i // COLS) + 1, col=(i % COLS) + 1)
fig4.update_xaxes({"visible": False, "showticklabels": False, "showgrid": False})
fig4.update_yaxes({"visible": True, "showticklabels": True, "showgrid": False})
fig4.update_yaxes(tickfont={"size": 11}, ticksuffix="   ")
fig4.write_image("eda-plotly-colors-sequential.svg")

fig3.update_layout({
    "title": "Palette de couleurs qualitatives Plotly Qualitative",
    "font": {"family": "Cabin", "size": 13},
    "xaxis": {"visible": False, "showticklabels": False},
    "yaxis": {"visible": False, "showticklabels": False},
    "legend": {"visible": False},
    "width": 1200,
    "margin": {"t": 100, "b": 50, "l": 60, "r": 50},
})
fig3.update_xaxes({"visible": False, "showticklabels": False, "showgrid": False})
fig3.update_yaxes({"visible": True, "showticklabels": True, "showgrid": False})
fig3.update_yaxes(tickfont={"size": 11}, ticksuffix="   ")
fig3.write_image("eda-plotly-colors-qualitative.svg")


