Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Lines+markers mode with Express

First thanks for Plotly Express. Great concept especially for us to introduce chemical engineering students (thus no dev background) to modern tools like JupyterLab for data exploration and analysis.

In one of our demo notebook we display recorded sensor data with scatter and mode=‘lines+markers’. After looking at the reference documentation I fail to see how to reproduce only within Express. Is there a way?

1 Like

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 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 for version 4.

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

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

We also have plans to improve this process of updating traces in the figure returned by a px function.

Hope that helps!


Excellent news. Looking forward to test drive newer versions as they come online.

What would you recommend as the cleanest way to apply the same update to all lines in a plot (pending future updates)? Thanks!

In version 3.9+ you can now update all traces in a figure using the update_traces method.

fig = (px.scatter(...)

See the docstring for fig.update_traces for more info.


I am wondering why we don’t have mode as an argument for px.scatter. I want to scatter with lines+markers and then color and facet_col, with marginal-y set to ‘violin’. I think getting this to work is beyond my complexity after spending an hour. So going back to the good old graph objects :slight_smile: Express is promising and hope it will address these needs in the future.

px.scatter() doesn’t support mode as an argument because this is served by the px.line() function :slight_smile:

With the code below

fig = go.FigureWidget()
fig.add_trace(go.Scattergl(x=df_kpi.index, y = df_kpi['output_signal'], name='Original', mode='lines+markers'))

I was expecting all the data points would be connected with the line, But what I see is a bit different, some data points arenot conencted with the line at all, and this is my first time seeing this. Why is this so?Any one has some idea?

This would be because you have nan values in your data. You can use connectgaps to prevent those:

        y = df_kpi['output_signal'],
1 Like