Plotly Express has an intuitive way to provide pre-formatted plotly plots with minimal lines of code; sort of how Seaborn does it for matplotlib.
It is possible to add traces of plots on Plotly to get a scatter plot on an existing line plot. However, I couldn't find such a functionality in Plotly Express.
Is it possible to combine a scatter and line graph in Plotly Express?
You can use:
Where
fig1
andfig2
are built usingpx.line()
andpx.scatter()
, respectively. Andfig3
is, as you can see, built usingplotly.graph_objects
.Some details:
One approach that I use alot is building two figures
fig1
andfig2
usingplotly.express
and then combine them using their data attributes together with ago.Figure / plotly.graph_objects
object like this:Plot: