Questions tagged [plotly-python]

Use this tag for questions about the interactive graphing library for Python.

References:

2059 questions
14
votes
3 answers

ModuleNotFoundError: No module named 'plotly.graph_objects'

Trying to use 'plotly.graph_objects' but I get this error ModuleNotFoundError: No module named 'plotly.graph_objects' How do I download module and apply using anaconda navigator
MSG
  • 343
  • 1
  • 3
  • 8
14
votes
2 answers

Plotly AttributeError: 'Figure' object has no attribute 'update_layout'

I am trying to add a title to my plot, but I get the error message: "AttributeError: 'Figure' object has no attribute 'update_layout'" The plot works without the update_layout line. I googled the error message without any luck. Is there any other…
Alberto Rocha
  • 553
  • 1
  • 5
  • 16
13
votes
4 answers

Plotly: How to color the fill between two lines based on a condition?

I want to add a fill colour between the black and blue line on my Plotly chart. I am aware this can be accomplished already with Plotly but I am not sure how to fill the chart with two colours based on conditions. The chart with the blue background…
Patrick Miller
  • 335
  • 1
  • 3
  • 8
13
votes
5 answers

Plotly: How to make a figure with multiple lines and shaded area for standard deviations?

How can I use Plotly to produce a line plot with a shaded standard deviation? I am trying to achieve something similar to seaborn.tsplot. Any help is appreciated.
Tyesh
  • 370
  • 2
  • 12
13
votes
3 answers

How do I control which trace plots on top with Plotly?

I'm using the Plotly python library to generate a figure with several violin plots and several filled scatter plots. No matter what order I have the individual fig.add_trace calls in my code, the violin plots always plot behind the scatter plots.…
Jonathan Fry
  • 643
  • 2
  • 7
  • 13
12
votes
1 answer

Plotly Table: Vertical align text in cells

How can I vertical align text inside Plotly Table cells? I can successfully set the height: go.Figure( data=[ go.Table( cells=dict( height=50, ) ) ] ) This looks awful:
Marian Rick
  • 3,350
  • 4
  • 31
  • 67
12
votes
1 answer

Plotly: How to set custom xticks

From plotly doc: layout > xaxis > tickvals: Sets the values at which ticks on this axis appear. Only has an effect if tickmode is set to "array". Used with ticktext. layout > xaxis > ticktext: Sets the text displayed at the ticks position via…
Mithril
  • 12,947
  • 18
  • 102
  • 153
12
votes
1 answer

Select/Copy Plotly Hovertext

Is there a way to lock hovertext in place when I click a datapoint? I would like to be able to click and HTML hyperlink in the text, or copy a key from the text into another system.
12
votes
1 answer

Plotly: How to filter a pandas dataframe using a dropdown menu?

I have a dataframe and using plotly I want to visualise the data. I have the following code fig = px.line(df, x="row_num", y="audienceWatchRatio", color='vid_id') fig.show() It's really messy, so I want a drop-down menu where the user can just…
Bryce Ramgovind
  • 3,127
  • 10
  • 41
  • 72
12
votes
2 answers

Python: How to make shaded areas or alternating background color using plotly?

Using only these few lines of code from plot.ly will give you the plot below in a jupyter notebook: Snippet 1: import plotly import cufflinks as cf from plotly.offline import download_plotlyjs, init_notebook_mode, plot,…
vestland
  • 55,229
  • 37
  • 187
  • 305
11
votes
2 answers

Plotly: How to toggle traces with a button similar to clicking them in legend?

I'm using python and creating standalone html files with interactive plots (no Dash). I have been able to build a plotly plot with buttons that can toggle the visibility of traces in the plot. However, this functionality removes the traces from the…
user2731076
  • 689
  • 1
  • 6
  • 21
11
votes
4 answers

Plotly: How to embed a fully interactive Plotly figure in Excel?

I'm trying to embed an interactive plotly (or bokeh) plot into excel. To do this I've tried the following three things: embed a Microsoft Web Browser UserForm into excel, following: How do I embed a browser in an Excel VBA form? This works and…
dusio
  • 480
  • 5
  • 18
11
votes
6 answers

Access Color from Plotly Color Scale

Is there a way in Plotly to access colormap colours at any value along its range? I know I can access the defining colours for a colourscale from plotly.colors.PLOTLY_SCALES["Viridis"] but I am unable to find how to access intermediate /…
JP-Ellis
  • 407
  • 5
  • 15
11
votes
3 answers

How to make a line plot from a pandas dataframe with a long or wide format

(This is a self-answered post to help others shorten their answers to plotly questions by not having to explain how plotly best handles data of long and wide format) I'd like to build a plotly figure based on a pandas dataframe in as few lines as…
vestland
  • 55,229
  • 37
  • 187
  • 305
11
votes
1 answer

Plotly: How to select graph source using dropdown?

I'm trying to embed multiple, selectable graphs in a single figure using Plotly, using a dropdown figure. I followed the dropdown example from Plotly, but they only show how to change graph characteristics (like visible, or type), not the underlying…
scnerd
  • 5,836
  • 2
  • 21
  • 36