[Python] Ignored font size of the math formula in Plotly

Discussão em 'Python' iniciado por Stack, Julho 3, 2025.

  1. Stack

    Stack Membro Participativo

    Take the following example of code for a plot in plotly:

    import plotly.graph_objects as go

    fig = go.Figure()
    fig.add_trace(go.Box(x = [r"$\mu", r"\sigma"], y=[10, 14]))
    fig.update_layout(xaxis=dict(tickfont=dict(size=24))
    fig.show()
    fig.write_image("this_image.png")


    The size has no impact on the font size of the xaxis's labels. On the other hand, if x values are a simple text like x=["mu", and "sigma"], it will be impacted by the size.

    Note that the solutions like using \displaystyle (e.g., r"$\displaystyle \mu" and r"\LARGE $\mu$") are not working and are ignored by the renderer.

    The engine of the image writer is "Kaleido" (kaleido==1.0.0, plotly==6.2.0, Python 3.12).

    The question is how to fix this issue for math formulas in the generate image?

    Continue reading...

Compartilhe esta Página