Questions tagged [plotly-python]

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

References:

2059 questions
85
votes
2 answers

Setting Background color to transparent in Plotly plots

My python code creates a plotly bar plot, but the background is white in color. I want to change it into transparent color. Is that doable? My Code: import plotly.plotly as py from plotly.graph_objs import * py.sign_in('username', 'api_key') data =…
The6thSense
  • 8,103
  • 8
  • 31
  • 65
75
votes
2 answers

How to set the range of the y axis

I have the following code to create the line plot with Plotly. How can I set the range of Y axis to always have it in [0; 10]? layout = go.Layout( title=go.layout.Title( text="Test", xref='paper', x=0 …
Tatik
  • 1,107
  • 1
  • 9
  • 17
57
votes
1 answer

How to change plotly figure size

I have made a scatter plot using matplotlib and Plotly. I want the height, width and the markers to be scatter as in matplotlib plot. Please see the attached plots. I used the following code in Plotly import plotly import plotly.plotly as py from…
hemanta
  • 1,405
  • 2
  • 13
  • 23
55
votes
6 answers

Interactive matplotlib figures in Google Colab

Normally in a jupyter notebook I would use %matplotlib notebook magic to display an interactive window, however this doesn't seem to work with google colab. Is there a solution, or is it not possible to display interactive windows in google colab?
skoeb
  • 805
  • 1
  • 6
  • 13
52
votes
5 answers

How to set line color

How can I set the color of a line in plotly? import plotly.graph_objects as go from plotly.subplots import make_subplots fig = make_subplots(rows=2, cols=1, subplot_titles=('Plot 1', 'Plot 2')) # plot the first line of the first…
Vader
  • 6,335
  • 8
  • 31
  • 43
43
votes
3 answers

How to hide legend with Plotly Express and Plotly

I am trying to learn Plotly by firstly creating a simple bar chart in Plotly Express and then updating it with Plotly to finesse it. I would like to hide the legend. I am trying to update the original figure by hiding the legend, and I can't get it…
krazykrejza
  • 579
  • 2
  • 6
  • 12
42
votes
3 answers

Use Pandas index in Plotly Express

Plotly Express allows me to easily plot a pandas dataframe, as explained in their examples. Rather than using a named column for x and a named column for y, I would like to use the dataframe's index for x and a named column for y. Example using…
Laurens Koppenol
  • 2,946
  • 2
  • 20
  • 33
41
votes
5 answers

How to change variable/label names for the legend in a plotly express line chart

I want to change the variable/label names in plotly express in python. I first create a plot: import pandas as pd import plotly.express as px d = {'col1': [1, 2, 3], 'col2': [3, 4, 5]} df = pd.DataFrame(data=d) fig = px.line(df, x=df.index,…
emil banning
  • 475
  • 1
  • 4
  • 8
41
votes
5 answers

How to save plotly express plot into a html or static image file?

However, I feel saving the figure with plotly.express is pretty tricky. How to save plotly.express or plotly plot into a individual html or static image file? Anyone can help?
roudan
  • 3,082
  • 5
  • 31
  • 72
41
votes
4 answers

Same scale for x and y axis

I am using plotly for python and I can't set x and y axis so they could have the same scale: Here is my layout: layout = Layout( xaxis=XAxis( range=[-150, 150], showgrid=True, zeroline=True, showline=True, …
farhawa
  • 10,120
  • 16
  • 49
  • 91
36
votes
4 answers

How to customize hover-template on with what information to show

Here is my dataset: After locking my dataframe by year and grouping by month, I proceed with calculating percentage increase/decrease as a new column; it ends up looking like this: Now for my Plotly plot I use this to display traces and add some…
DGomonov
  • 715
  • 1
  • 7
  • 19
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
35
votes
2 answers

Plotly/Dash display real time data in smooth animation

We are trying to produce a real-time dashboard in plotly-dash that displays live data as it is produced. We are generally following the guidance here (https://dash.plotly.com/live-updates). We have a callback that gathers a chunk of new data points…
David Parks
  • 30,789
  • 47
  • 185
  • 328
34
votes
4 answers

Saving multiple plots into a single html

I recently discovered plotly and find it really good for graphing, now I have a problem which I want to save multiple plot into a single html, how to do it please? *I want to save multiple plot, i.e fig, fig1, fig 2 and so on, NOT one subplot which…
Victor
  • 659
  • 3
  • 8
  • 19
31
votes
1 answer

How to define colors in a figure using Plotly Graph Objects and Plotly Express

There are many questions and answers that touch upon this topic one way or another. With this contribution I'd like to clearly show why an easy approch such as marker = {'color' : 'red'} will work for plotly.graph_objects (go), but color='red' will…
vestland
  • 55,229
  • 37
  • 187
  • 305
1
2 3
99 100