Skip to content

Kaleido v1.0.0 cannot display latex formula normally #360

@Lucky8-GH

Description

@Lucky8-GH

Kaleido v0.2.1 and v1.0.0 generate very different pictures.

The picture Latex display effect of kaleido v1.0.0 is abnormal.

1. Create a file named main.py

import time

import plotly.graph_objects as go


def write_chart():
    fig = go.Figure()

    lcl = 5.123456789
    mean = 10.123456789
    ucl = 15.123456789

    for y in [lcl, mean, ucl]:
        fig.add_trace(
            go.Scatter(
                x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                y=[y] * 10,
                mode="lines",
            )
        )

    fig.update_layout(
        plot_bgcolor="white",
        title="This is a title",
        showlegend=False,
        xaxis=dict(
            title="This is x axis",
            mirror=True,
            linecolor="grey",
            ticks="outside",
        ),
        yaxis=dict(
            side="right",
            mirror=True,
            linecolor="grey",
            ticks="outside",
            tickvals=[lcl, mean, ucl],
            ticktext=[
                "$\\text{Lower line  = " + str(lcl) + "}$",
                "$\\mathrm{\\overline{\\overline{X}} = " + str(mean) + "}$",
                "$\\text{Upper line = " + str(ucl) + "}$",
            ],
        ),
    )

    # show fig
    fig.show()

    # save image
    fig.write_image(f"{time.strftime('%Y%m%d%H%M%S')}.png", scale=3)


if __name__ == "__main__":
    write_chart()

2. kaleido v1.0.0 Install in a brand new Env

pip install kaleido==1.0.0  plotly==6.2.0 

2.1. Execute command: python3 main.py

python3 main.py

2.2. The generated png graphics are:

Image

3. kaleido v0.2.1 Install in a brand new Env

pip install kaleido==0.2.1  plotly==6.2.0

3.1. Execute command: python3 main.py

❯❯❯ python3 main.py
/Users/gh/Desktop/TestFile/main.py:50: DeprecationWarning:


Support for Kaleido versions less than 1.0.0 is deprecated and will be removed after September 2025.
Please upgrade Kaleido to version 1.0.0 or greater (`pip install 'kaleido>=1.0.0'` or `pip install 'plotly[kaleido]'`).

3.2. The generated png graphics are:

Image

4. The Latex content shown on the Y-axis to the right of the image is very different.

Metadata

Metadata

Assignees

Labels

P1needs immediate attentionbugsomething brokenregressionthis used to work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions