Questions tagged [plotly-express]

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.

365 questions
9
votes
1 answer

Plotly: How to show legend in single-trace scatterplot with plotly express?

Sorry beforehand for the long post. I'm new to python and to plotly, so please bear with me. I'm trying to make a scatterplot with a trendline to show me the legend of the plot including the regression parameters but for some reason I can't…
9
votes
2 answers

Plotly-Express: How to fix the color mapping when setting color by column name

I am using plotly express for a scatter plot. The color of the markers is defined by a variable of my dataframe, as in the example below. import pandas as pd import numpy as np import plotly.express as px df = px.data.iris() fig =…
otwtm
  • 1,779
  • 1
  • 16
  • 27
9
votes
2 answers

order bars in bar chart by value in descending order with plotly-express

I need to make a plotly bar chart with bars ordered by value in descending order. I first order the dataframe by value in descending order. Then I use plotly.express to generate interactive bar chart. However, I found the bars are still in ascending…
zesla
  • 11,155
  • 16
  • 82
  • 147
8
votes
2 answers

How to highlight a single data point on a scatter plot using plotly express

In a scatter plot created using px.scatter, how do I mark one data point with a red star? fig = px.scatter(df, x="sepal_width", y="sepal_length") # Now set a single data point to color="red", symbol="star".
8
votes
1 answer

How to update plotly express treemap to have both label as well as the value inside the plot?

Currently, plotly express treemap shows only label inside treemap. How to include the value alongside the label?
imdevskp
  • 2,103
  • 2
  • 9
  • 23
7
votes
5 answers

Plotly Express timeline for Gantt Chart with integer xaxis?

I'm using plotly express timeline to produce a Gantt chart following this example: https://medium.com/dev-genius/gantt-charts-in-python-with-plotly-e7213f932f1e It automatically sets the x-axis to use dates but I'd actually like to just use integers…
Rob
  • 1,336
  • 1
  • 15
  • 24
7
votes
2 answers

How to have just one trendline for multiple colors in plotly express scatter?

I want to create a scatter plot with only one trendline. Plotly express creates a different trendline for each color in the points list. import plotly.express as px value = [15, 20, 35, 40, 48] years = [2010, 2011, 2012, 2013, 2014] colors =…
jgmh
  • 639
  • 10
  • 22
7
votes
3 answers

Animated plotly-express graph not showing up in jupyter-lab

The following example produces an animated graph that can be displayed with jupyter notebook, but in jupyter-lab the graph does not show up. %pylab inline import plotly.express as px gapminder = px.data.gapminder() px.scatter(gapminder,…
Soerendip
  • 7,684
  • 15
  • 61
  • 128
6
votes
2 answers

How To Create Subplots Using Plotly Express

If you’re like me, you love Plotly Express, but were frustrated when you ran into the issue that figures returned by Express can’t utilize ‘make_subplots()’ since make_subplots takes in traces and not figures. With this post, I’d like to share my…
mmarion
  • 859
  • 8
  • 20
6
votes
1 answer

plotly express plots have faded colors

I am having issues with plotly express in Jupyter notebook. The colors in the plot are faded and do not match the colors in the legend, which they are supposed to look like. Does anyone have any suggestions? Happy to provide more info, but I am not…
nateswill
  • 151
  • 5
6
votes
1 answer

Change hover text of a plotly express treemap

I want to show in a treemap just the label and value of each item, not parent or ID. I have defined it with plotly express. No matter how much I have tinkered with it, I haven’t been able to restrict hover text to the fields I need. Check the code…
6
votes
1 answer

Plotly Express hover options

In plotly_express.line the only options I see to modify hover settings are hover_name and hover_data. A few issues I'm facing with modifying hover are: It seems that even if I set hover_data=None it still shows the values for name,x, and y. How can…
Austin
  • 6,921
  • 12
  • 73
  • 138
5
votes
1 answer

How to reorder measures in customizing hover label appearance plotly?

I'm making an interactive map, there is no problem with the map itself, there is a problem with the way the elements are located in the additional hover marks. Is there any way to change this order? Is it possible not to display latitude and…
kostya ivanov
  • 613
  • 5
  • 15
5
votes
1 answer

Removing the white border around Plotly chart in Python

How can I remove the white margin/border around the figure? import pandas as pd import numpy as np import plotly.express as px df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c']) fig =…
kharoufeh
  • 51
  • 1
  • 3
5
votes
1 answer

How to adjust plotly express area chart size?

I've created a plotly express area chart on Dash app. The chart works fine however the 1st point and the last point on x-axis seems to be getting out of the chart and can been seen only in half (as shown in the attach screenshot). I've also tried…
1
2
3
24 25