Lines+markers mode with Express

Hi @cfoisy,

Thanks for the kind words on plotly express. Glad you’re enjoying it and that you see it as something that will be useful to pick up for your engineering students!

Unlike plotly.py, plotly express separates scatter and line into two separate functions so that the compatible options are clearer in the API. So I think the plan is that eventually you’ll make this kind of plot as two separate px calls (one for px.line and one for px.scatter), and then overlay them into a single figure. But, we don’t have the overlay operation implemented yet so at the moment you can’t easily combine the results of multiple px calls. This is something we plan to address before merging plotly express into plotly.py for version 4.

In the meantime, you can take advantage of the fact that the figures returned by plotly express are plotly.py figures that can be modified before being displayed. So you could do something like

fig = px.scatter(df, ...)
fig.data[0].update(mode='markers+lines')
fig

We also have plans to improve this process of updating traces in the figure returned by a px function. https://github.com/plotly/plotly.py/issues/1484.

Hope that helps!
-Jon

4 Likes