I'm trying to plot a vertical line that's dynamically positioned so that when filtering happens, the line will move accordingly. For example, with the below code, I can plot a stationary vertical line at 25K which works with the full dataset as the median, but when the data is filtered to "Americas" only since the x-axis range is now 45K, the line is not at the median position anymore.
So how can I plot a vertical line that's positioned at the x-axis range's median position? Thanks
import pandas as pd
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
df = pd.read_csv('https://raw.githubusercontent.com/yankev/test/master/life-expectancy-per-GDP-2007.csv')
americas = df[(df.continent=='Americas')]
europe = df[(df.continent=='Europe')]
trace_comp0 = go.Scatter(
x=americas.gdp_percap,
y=americas.life_exp,
mode='markers',
marker=dict(size=12,
line=dict(width=1),
color="navy"
),
name='Americas',
text=americas.country,
)
trace_comp1 = go.Scatter(
x=europe.gdp_percap,
y=europe.life_exp,
mode='markers',
marker=dict(size=12,
line=dict(widt