简体   繁体   中英

How to display the values above markers in plotly scatter graph object?

I can't seem to find the argument to always display the scatter y values above the points in python plotly.

I tried to search for it and failed. I just want something like that hover number to always be on.

Do you need something similar to this in the docs? https://plotly.com/python/line-and-scatter/#connected-scatterplots

import plotly.express as px

df = px.data.gapminder().query("country in ['Canada', 'Botswana']")

fig = px.scatter(
        df, x="lifeExp", y="gdpPercap", color="country", text="year"
    ).update_traces(textposition="top center")
fig.show()

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM