The plotly.express module (usually imported as px) contains functions that can create entire figures at once, and is referred to as Plotly Express or PX. Plotly Express is a built-in part of the plotly library, and is the recommended starting point for creating most common figures.
Questions tagged [plotly-express]
365 questions
36
votes
3 answers
How to plot multiple lines on the same y-axis using Plotly Express in Python
I just installed plotly express. And I am trying to do something simple - plot each column of my data frame on the same y-axis with the index as x-axis. Here are questions/observations:
Is it necessary for the data frame to have index as a column to…

UGuntupalli
- 769
- 1
- 9
- 22
29
votes
3 answers
How to manually set the color of points in plotly express scatter plots
https://plotly.com/python/line-and-scatter/ has many scatter plot examples, but not a single one showing you how to set all the points' colours within px.scatter:
# x and y given as DataFrame columns
import plotly.express as px
df = px.data.iris() #…

RNs_Ghost
- 1,687
- 5
- 25
- 39
28
votes
4 answers
How to combine scatter and line plots using Plotly Express
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.…

Ébe Isaac
- 11,563
- 17
- 64
- 97
28
votes
2 answers
How to plot on secondary y-Axis with plotly express
How do I utilize plotly.express to plot multiple lines on two yaxis out of one Pandas dataframe?
I find this very useful to plot all columns containing a specific substring:
fig = px.line(df, y=df.filter(regex="Linear").columns,…

derflo
- 981
- 1
- 7
- 9
25
votes
4 answers
Save Jupyter Notebook with Plotly Express widgets displaying
I have a Jupyter notebook (python) where I used plotly express to plot in the notebook for analysis purposes.
I want to share this notebook with non-coders, and have the interactive visuals be available still - but it does not seem to work.
I tried…

guyts
- 899
- 2
- 17
- 34
24
votes
7 answers
How to hide the colorbar and legend in plotly express bar graph?
I am creating a bar graph with something like this:
px.bar(df, x=x, y=y, color=c,
title=params['title'],
hover_data=hover_data)
When c != None the graph produces either a legend or a colorbar. How can I remove either of them?

Soerendip
- 7,684
- 15
- 61
- 128
22
votes
2 answers
How to add points or markers to line chart using plotly express?
plotly.express is very convenient to produce nice interactive plots. The code below generates a line chart colored by country. Now what I need is to add points to the plot. Does anyone know how I can add points to the line chart?
import…

zesla
- 11,155
- 16
- 82
- 147
19
votes
3 answers
Overlaying two histograms with plotly express
I'd like to overlay two histograms which I currently display only one next to the other using the following simplistic code. The two dataframes are not the same length, but it still makes sense to overlay their histogram values.
import…

matanster
- 15,072
- 19
- 88
- 167
18
votes
1 answer
Set all markers to the same fixed size in Plotly Express scatterplot
I'm looking for a way to set all markers in a Plotly Express scatter plot to the same size.
I want to specify that fixed size myself.
I know you can use a variable to set as size of the markers (with px.scatter(size='column_name'), but then they…

Sander van den Oord
- 10,986
- 5
- 51
- 96
18
votes
1 answer
How can I make faceted plots in Plotly have their own individual YAxes tick labels?
When I use Plotly express to plot different parameters with different ranges - in the example below, BloodPressureHigh, Height(cm), Weight(kg), and BloodPressureLow - using the facet_col argument, I am unable to get the resulting plot to display the…

Sam Jett
- 710
- 1
- 6
- 15
17
votes
5 answers
Change Line Colour with Plotly Express
I have a plotly express figure:
fig = px.line(data, x="DateTime", y="Gold", title="Gold Prices")
I want to change some details, like so
fig.update_layout(
line_color="#0000ff", # ValueError: Invalid property specified for object of type…

Robin Andrews
- 3,514
- 11
- 43
- 111
17
votes
5 answers
Plotly express is not rendered in jupyter lab
The following code does not render in Jupyter lab:
%matplotlib widget
import plotly.express as px
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.randint(0,100,size=(5, 4)), columns=list('ABCD'))
px.bar(df, x='A', y='B')
I…

Mth Clv
- 625
- 1
- 7
- 20
13
votes
3 answers
Single axis caption in plotly express facet plot
I am learning to use pyplot.express and struggle with the following design problem: In faceted plots, the axis title is repeated for every subplot (in the example case 'petal width (cm)'). Is there a way to get a single axis label for all subplots…

MichaG
- 457
- 5
- 11
10
votes
1 answer
subplots with plotly express 4
I have the following, using plotly express:
fig = px.line(series1, x='timestamp', y='data')
fig.show()
and it works properly.
I want to make multiple plots together, so I did:
fig = make_subplots(rows=2, cols=1)
fig.add_trace(px.line(series1,…

Thomas
- 10,933
- 14
- 65
- 136
9
votes
2 answers
Plotly: How to update / redraw a plotly express figure with new data?
During debugging or computationally heavy loops, i would like to see how my data processing evolves (for example in a line plot or an image).
In matplotlib the code can redraw / update the figure with plt.cla() and then plt.draw() or…

Jim
- 1,579
- 1
- 11
- 18