0

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.

Fil B
  • 11
  • Try reading through [the documentation](https://plotly.com/python/text-and-annotations/#text-on-scatter-plots-with-graph-objects) on `annotations` – that looks like what you want. Also some advice for questions since you're new – saying "I tried to search and failed" makes it sound like you didn't put in much effort (I didn't downvote though). Instead I would recommend including any code you've written, image(s) showing the desired output, or links to any documentation you've looked at because these all show you made an effort and give people a starting point to help you. – Derek O Nov 25 '22 at 02:21

1 Answers1

0

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()

enter image description here

DougR
  • 3,196
  • 1
  • 28
  • 29