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
5
votes
3 answers
Is there a way to use Plotly express to show multiple subplots
I'm keen to know if there is an equivalent to:
import pandas as pd
import numpy as np
data = pd.DataFrame({'Day':range(10),
'Temperature': np.random.rand(10),
'Wind': np.random.rand(10),
…

Myccha
- 961
- 1
- 11
- 20
5
votes
3 answers
Plotly: How to add text labels to a histogram?
Is there a way how to display the counted value of the histogram aggregate in the Plotly.Express histogram?
px.histogram(pd.DataFrame({"A":[1,1,1,2,2,3,3,3,4,4,4,5]}),x="A")
If I would use regular histogram, I can specify text parameter which…

Vaasha
- 881
- 1
- 10
- 19
5
votes
2 answers
How do I set dot sizes and colors for a plotly express scatter_geo?
I have an example data set (pd.read_clipboard(sep='\s\s+') to read into pandas):
reference Latitude Longitude year subreg dot_size
date
1984-08-05 1985-12 24.033333 59.916667 1984 62 80
1984-08-02 …

hrokr
- 3,276
- 3
- 21
- 39
5
votes
3 answers
Plotly: Change order of elements in Sunburst Chart
I am currently using plotly express to create a Sunburst Chart. However, i realized that children are ordered alphabetical for nominal values. Especially for plotting months that is pretty unlucky... Do you know how to handle that issue? Maybe a…

LK1999
- 113
- 6
5
votes
1 answer
Plotly: Dodge overlapping points on scatterplot categorical axis
I am trying to use plotly to compare the coefficents of regression models using error bars for the confidence intervals. I used the following code to plot it, using the variable as a categorical y axis in a scatter plot. The problem is that the…

Daniel R
- 1,954
- 1
- 14
- 21
5
votes
1 answer
Reverse legend order without changing bar order in plotly express bar plot
I'd like to change the order of the items in the legend of a plotly.express bar plot.
For example, I'd like to show Dinner before Lunch on this plot (the current behavior is especially awkward with horizontal bar plots, since the order of the bars…

Max Ghenis
- 14,783
- 16
- 84
- 132
5
votes
2 answers
Plotly: How to change background color of a plotly express legend?
The commented out line is my best guess.
def _make_json(self, given_panda: pd.DataFrame, sort_by: str) -> str:
figure = px.scatter_mapbox(given_panda,
hover_name='City',
…

Matchinski
- 65
- 1
- 1
- 5
5
votes
3 answers
Is there any way to implement Stacked or Grouped Bar charts in plotly express
I am trying to implement a grouped-bar-chart (or) stacked-bar-chart in plotly express
I have implemented it using plotly (which is pretty straight forward) and below is code for it. There are altogether six columns in dataframe ['Rank', 'NOC',…

chamanthmvs
- 51
- 1
- 1
- 4
4
votes
1 answer
Bar polar with areas proportional to values
Based on this question I have the plot below.
The issue is plotly misaligns the proportion between plot area and data value. I mean, higher values (e.g. going from 0.5 to 0.6) lead to a large increase in area (big dark green block) whereas from 0 to…

user3507584
- 3,246
- 5
- 42
- 66
4
votes
1 answer
Why is plotly express so much more performant than plotly graph_objects?
I'm visualizing a scatterplots with between 400K and 2.5M points. I expectected to need to downsample before visualizing but to see just how much I ran a pilot test with a 400k dataset in plotly express, and the plot popped up quickly, beautifully,…

psychicesp
- 182
- 6
4
votes
2 answers
TypeError: line() got an unexpected keyword argument 'markers'
I'm trying to use "markers" for the line function with plotly 5.4.0
import plotly.express as px
df_temp = df_temp[df_temp.date_str.isin(selected_dates)]
fig = px.line(df_temp, x='trialID', y='reaction_time', color='date_str',…

al rein
- 41
- 1
- 2
4
votes
1 answer
Remove color to the right of custom hovercard in Plotly Express
When creating custom hovercards in plotly express via the custom_data/hovertemplate paradigm, the color is shown to the right of it. For example, here shows "blue" just to the right of "a=1". How can I remove the "blue"?
import pandas as pd
import…

Max Ghenis
- 14,783
- 16
- 84
- 132
4
votes
1 answer
plotly (px) animation_frame error with datetime not being accepted
I want to make an animate bar graph similar to the following example by plotly: https://plotly.com/python/animations/
I have following code:
fig = px.bar(
eu_vaccine_df.sort_values('date'),
x='country', y='people_vaccinated_per_hundred',
…

Sebastian ten Berge
- 137
- 2
- 11
4
votes
1 answer
How do I display a timedelta in the format HH:MM:SS on my Plotly Express line chart's axis?
I want to plot a continuous 'Time' column against dates on a simple timeseries linechart in plotly express. The 'Time' column starts out as a string, in the format HH:MM:SS, but when I plot this outright it is treated as discrete values. To remedy…

artfulinfo
- 108
- 1
- 11
4
votes
0 answers
How to add 1 more breakdown color in plotly funnel?
I have 1 state on "og"- false, and 2 states on "no og" true and false
is_retargeting
media_source
step
Values
False
og
step1
31992
True
no og
step1
33644
False
no og
step1
32199
False
no og
step2
20699
False
og
step2
47796
True
no…

mrDaft
- 43
- 6