Plotly log 刻度显示完整的刻度值

Plotly log scale show full tick values

考虑 the code in the example

import plotly.express as px
df = px.data.gapminder().query("year == 2007")

fig = px.scatter(df, x="gdpPercap", y="lifeExp", hover_name="country", log_x=True)
fig.show()

并生产

x轴上的刻度是否可能显示200020k等而不是2,[=15也是如此=], 4 ... ?

import plotly.express as px
import numpy as np
import pandas as pd

df = px.data.gapminder().query("year == 2007")

fig = px.scatter(df, x="gdpPercap", y="lifeExp", hover_name="country", log_x=True)
fig.update_layout(
    xaxis={
        "tickmode": "array",
        "tickvals": pd.to_numeric(
            [f"{n:.1g}" for n in np.geomspace(1, df["gdpPercap"].max(), 15)]
        ),
    }
)