1import plotly.express as px
2
3df = px.data.gapminder().query("continent == 'Africa'")
4
5fig = px.line(df, x="year", y="lifeExp", facet_col="country", facet_col_wrap=7,
6 facet_row_spacing=0.04, # default is 0.07 when facet_col_wrap is used
7 facet_col_spacing=0.04, # default is 0.03
8 height=600, width=800,
9 title="Life Expectancy in Africa")
10fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
11fig.update_yaxes(showticklabels=True)
12fig.show()
13