I would like to have a line going up to the lowest scatter point.
For instance, below the point ("ANO3", "EM PRODUÇÃO") there would be a line or bar.
Can this be done in plotly?
I would like to have a line going up to the lowest scatter point.
For instance, below the point ("ANO3", "EM PRODUÇÃO") there would be a line or bar.
Can this be done in plotly?
Here's one very felxible approach:
fig.add_trace(
go.Bar(
x=[df_min['gdpPercap'].iloc[0]],
y=[df_min['lifeExp'].iloc[0]],
marker=dict(line=dict(width=4, color = 'blue'))
))
import plotly.express as px
import plotly.graph_objects as go
import pandas as pd
fig = go.Figure()
df = px.data.gapminder().query("year == 2007 & continent == 'Europe'")
df_min = df[df['lifeExp'] == df['lifeExp'].min()]
fig = px.scatter(df, x="gdpPercap", y="lifeExp", hover_name="country")
fig.add_trace(
go.Bar(
x=[df_min['gdpPercap'].iloc[0]],
y=[df_min['lifeExp'].iloc[0]],
marker=dict(line=dict(width=4, color = 'blue'))
))
fig.update_layout(yaxis_range=[70,80])
fig.show()