Questions tagged [plotly]

Plotly.js is an open source, high-level, declarative charting library, built on top of d3.js and stack.gl. It ships with over 40 chart types, including 3D charts, statistical graphs, and SVG maps. Use [r-plotly] for the R package and [plotly-python] for the Python package.

plotly
Filter by
Sorted by
Tagged with
103 votes
12 answers
198k views

Plotly chart not showing in Jupyter notebook

I have been trying to solve this issue for hours. I followed the steps on the Plotly website and the chart still doesn't show in the notebook. This is my code for the plot: colorway = ['#f3cec9', '#...
Guillermina's user avatar
  • 3,397
96 votes
1 answer
58k views

Flex items not shrinking when window gets smaller [duplicate]

I'm trying to fit two plotly plots next to each other inside a CSS flexbox. I want them to resize when the window is resized. It works as expected when the window grows, but the plots don't shrink ...
Alexander Schlüter's user avatar
94 votes
3 answers
188k views

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 ...
The6thSense's user avatar
  • 8,263
90 votes
9 answers
165k views

ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed

I was trying to print a plotly plot in Visual Studio Code and caught this error: --------------------------------------------------------------------------- ValueError ...
nilsinelabore's user avatar
81 votes
2 answers
223k views

Set the range of the y axis in Plotly

I made a 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's user avatar
  • 1,167
75 votes
14 answers
121k views

save plotly plot to local file and insert into html

I am using python and plotly to product interactive html report. This post gives a nice framework. If I produce the plot(via plotly) online, and insert the url into the html file, it works but ...
cone001's user avatar
  • 1,143
67 votes
2 answers
152k views

TypeError: Object of type 'DataFrame' is not JSON serializable

I'm trying to create a plotly graph with some data I've got from my PostgreSQL server, but when I try to graph I'm getting an error: "TypeError: Object of type 'DataFrame' is not JSON serializable" ...
peolss's user avatar
  • 673
63 votes
5 answers
171k views

TypeError: load() missing 1 required positional argument: 'Loader' in Google Colab

I am trying to do a regular import in Google Colab. This import worked up until now. If I try: import plotly.express as px or import pingouin as pg I get an error: -----------------------------------...
user17147261's user avatar
  • 1,191
63 votes
1 answer
148k views

How to change plotly figure size

I made the following scatter plot with Plotly: import plotly import plotly.plotly as py from plotly.graph_objs import Scatter import plotly.graph_objs as go trace1 = go.Scatter( x=x1_tsne, # x-...
hemanta's user avatar
  • 1,450
60 votes
5 answers
112k views

Change line color in Plotly

How do 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')) # ...
Vader's user avatar
  • 6,526
60 votes
7 answers
64k views

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 ...
skoeb's user avatar
  • 855
59 votes
4 answers
57k views

How to choose variable to display in tooltip when using ggplotly?

I have a simple data frame: seq <- 1:10 name <- c(paste0("company",1:10)) value <- c(250,125,50,40,40,30,20,20,10,10) d <- data.frame(seq,name,value) And I want to plot it this way: ...
Malta's user avatar
  • 1,923
57 votes
2 answers
48k views

What are the pros and cons of Dash by Plotly vs Jupyter Dashboards? [closed]

Dash by Plotly looks like a great way for a Python developer to create interactive web apps without having to learn Javascript and Front End Web development. Another great project with similar aims ...
snth's user avatar
  • 5,429
54 votes
7 answers
55k views

plot.ly offline mode in jupyter lab not displaying plots

According to the documentation, offline mode with plot.ly in Jupyter is supposed to work after calling: from plotly.offline import download_plotlyjs, init_notebook_mode, iplot init_notebook_mode(...
clstaudt's user avatar
  • 22k
52 votes
4 answers
111k views

What is the process to create pdf reports with charts from a DB?

I have a database generated by a survey to evaluate university professors. What I want is a python script that takes the information from that database, generates a graphing table for each user, ...
ozo's user avatar
  • 893
51 votes
5 answers
55k views

Plotly notebook mode with google colaboratory

I am am trying out colaboratory with plotly notebook mode - I open a new notebook, copy and paste the following simple example from plotly's documentation, but don't see an output. There is a large ...
elz's user avatar
  • 5,558
49 votes
3 answers
70k views

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 ...
krazykrejza's user avatar
48 votes
3 answers
131k views

How to plot 3D scatter diagram using ggplot?

I tried to use the plotly package, but it is not working in my case at all. The ggplot package is working for 2D plots but it is giving an error when adding one more axis. How to solve this issue? ...
R June's user avatar
  • 655
48 votes
7 answers
107k views

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's user avatar
  • 3,726
47 votes
5 answers
92k views

How to use dash within Jupyter notebook or JupyterLab?

Is it possible to have a dash app within a Jupyter Notebook, rather than served up and viewed in a browser? My intention is to link graphs within a Jupyter notebook so that hovering over one graph ...
bluprince13's user avatar
  • 4,767
46 votes
5 answers
80k views

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....
emil banning's user avatar
45 votes
3 answers
49k views

Formatting mouse over labels in plotly when using ggplotly

I am struggling with text formatting when using ggplotly and the mouse over functionality. library(plotly) df <- data.frame(a=letters, b=LETTERS, x=runif(26), y=runif(26)) g <- ggplot(df, aes(x,...
drmariod's user avatar
  • 11.5k
45 votes
1 answer
48k views

Remove space between subplots in Plotly?

I have a a large space in between my subplots in plotly. In matplotlib, there is a layout called a tight layout that removes this. Is there any similar layout in plotly? I am plotting in an iPython ...
pr338's user avatar
  • 8,910
44 votes
3 answers
58k views

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 ...
Laurens Koppenol's user avatar
43 votes
4 answers
74k views

Disable hover information on trace, plotly

I'm currently using the plotly service to graph some water quality data. I've added some lines to represent the the various stages of water quality, with them shaded so they are green, yellow, and red....
ChrisDevWard's user avatar
42 votes
4 answers
75k views

Horizontal/Vertical Line in plotly

I'm using the plotly package and I'm trying to add a horizontal line to a graph. Is there any way of doing it using plotly? It can be done using ggplot2 and the ggplotly function as shown below: ...
Sam Helmich's user avatar
42 votes
4 answers
60k views

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, ...
farhawa's user avatar
  • 10.3k
41 votes
4 answers
49k views

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 ...
Victor's user avatar
  • 739
40 votes
2 answers
72k views

how to hide plotly yaxis title (in python)?

Editing: The following example from Plotly for reference: import plotly.express as px df = px.data.gapminder().query("continent == 'Europe' and year == 2007 and pop > 2.e6") fig = px.bar(df, y='...
ZKK's user avatar
  • 701
40 votes
2 answers
49k views

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 ...
David Parks's user avatar
  • 31.2k
40 votes
6 answers
63k views

how can i create subplots with plotly express?

been loving the plotly express graphs but want to create a dashboard with them now. Did not find any documentation for this. Is this possible?
Animesh Dwivedi's user avatar
40 votes
3 answers
98k views

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 ...
UGuntupalli's user avatar
39 votes
8 answers
46k views

Plotly.js default colors list

How do I obtain the default colors list / palette for plots with multiple series? (e.g. bubble chart)
Sushil Kumar's user avatar
  • 1,469
39 votes
2 answers
12k views

Plotly express vs. Altair/Vega-Lite for interactive plots

Recently I am learning both Plotly express and Altair/Vega-Lite for interactive plotting. Both of them are quite impressive and I am wondering what their strengths and weaknesses are. Especially for ...
roudan's user avatar
  • 3,726
38 votes
4 answers
102k views

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 ...
DGomonov's user avatar
  • 765
38 votes
3 answers
49k views

Embedding a Plotly chart in a Django template

I am trying to embed a plotly pie chart in a Django html template. This works fine when the chart is produced in 'online mode' (i.e. the html snippet is stored on the plotly server) but not in '...
Hooloovoo's user avatar
  • 875
36 votes
3 answers
79k views

how to set the bold font style in Plotly

When using the Plotly, I can set the title font in the layout part as follow. titlefont=dict(size =14, color='black', family='Arial, sans-serif') My question is How to set the font as Bold. Thanks
Jason LiLy's user avatar
36 votes
15 answers
29k views

plotly.offline.iplot gives a large blank field as its output in Jupyter Notebook/Lab

I am trying to create a Sankey chart in a Jupyter notebook, basing my code on the first example shown here. I ended up with this, which I can run without getting any errors: import numpy as npy ...
eirikdaude's user avatar
  • 3,164
36 votes
7 answers
47k views

How to reverse axis values when using plotly?

Here is the program I used: library(plotly) mydata = read.csv("data_to_plot.txt") df = as.data.frame(mydata) p <- df %>% group_by(X) %>% plot_ly(x = ~Y, y = ~X, z = ~Z, type = "...
Andrew's user avatar
  • 1,050
36 votes
8 answers
4k views

How to embed Plotly graphs in Sphinx documentation and nbsphinx

I tried using nbsphinx to embed a Jupyter notebook containing plotly plots, but the plots don't show up in the documentation, even though they look fine on the Jupyter notebook. How can I embed a ...
bluprince13's user avatar
  • 4,767
36 votes
0 answers
1k views

Interactive selection in ggplotly with geom_hex() scatterplot

I am trying to create a scatterplot matrix with interactive selection between geom items in individual matrix plots. This works when I am dealing with geom_points (inside ggpairs()). When a user ...
user avatar
35 votes
2 answers
41k views

Using R and plot.ly - how do I script saving my output as a webpage

I want to make some interactive graphs using R and plot.ly. When I run the following code in R-Studio, it produces an interactive graph. library(plotly) set.seed(100) d <- diamonds[sample(nrow(...
Slavatron's user avatar
  • 2,318
35 votes
1 answer
73k views

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 ...
vestland's user avatar
  • 58.3k
34 votes
4 answers
47k views

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 ...
Ébe Isaac's user avatar
34 votes
1 answer
21k views

How to add line breaks to plotly hover labels

Is there a way to get plotly to display the hover text on multiple lines/get it to recognize special characters line '\n' in the text? A dummy version of what I'm looking to do is: data <- data....
rabbert_klein's user avatar
33 votes
6 answers
85k views

How can I change the size of my Dash Graph?

I'm running into layout difficulties with the plots on Dash. All the plots I generate with Dash seem to be auto sized to be very narrow, which makes it hard to actually view the data without some ...
FelixVelariusBos's user avatar
33 votes
1 answer
5k views

Highlight all values from a group on hover

Assume data library(ggplot2) library(plotly) set.seed(357) xy <- data.frame(letters = rep(c("a", "b", "c"), times = 3), values = runif(9), groups = rep(c("group1"...
Roman Luštrik's user avatar
32 votes
3 answers
45k views

Ordering in r plotly barchart

Why do I get the different order in plotly bar chart than I defined in x and y variables. E.g. library(plotly) plot_ly( x = c("giraffes", "orangutans", "monkeys"), y = c(20, 14, 23), name = "...
martinkabe's user avatar
  • 1,099
32 votes
1 answer
35k views

Listing legend items horizontally and centered below a plot

I have been tweaking legends in plotly and R. One thing I am unable to figure out is how (if it is possible) to reposition legend items so that they are listed horizontally and centered below the plot....
user avatar

1
2 3 4 5
312