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.
14,886
questions
88
votes
11
answers
163k
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', '#...
87
votes
1
answer
50k
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 ...
85
votes
2
answers
167k
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 ...
75
votes
14
answers
112k
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 ...
70
votes
2
answers
177k
views
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="...
65
votes
7
answers
96k
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 ...
64
votes
2
answers
128k
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"
...
58
votes
4
answers
52k
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:
...
55
votes
4
answers
133k
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:
-----------------------------------...
55
votes
2
answers
46k
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 ...
53
votes
7
answers
51k
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(...
53
votes
6
answers
57k
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 ...
51
votes
5
answers
89k
views
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'))
# ...
51
votes
4
answers
102k
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, ...
51
votes
1
answer
115k
views
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 ...
50
votes
5
answers
49k
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 ...
48
votes
3
answers
115k
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?
...
45
votes
3
answers
45k
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,...
45
votes
5
answers
84k
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 ...
44
votes
1
answer
39k
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 ...
41
votes
4
answers
51k
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,
...
40
votes
4
answers
72k
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:
...
40
votes
3
answers
50k
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 ...
39
votes
4
answers
63k
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....
38
votes
7
answers
40k
views
How to get Plotly.js default colors list?
I am plotting a plotly bubble chart on a webpage.. I want to get the list of default colors, plotly uses to draw the bubbles.
37
votes
3
answers
46k
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 '...
37
votes
5
answers
59k
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....
37
votes
3
answers
51k
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 ...
36
votes
4
answers
74k
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?
35
votes
4
answers
82k
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 ...
35
votes
2
answers
37k
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 ...
35
votes
2
answers
9k
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 ...
35
votes
8
answers
3k
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 ...
34
votes
2
answers
58k
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='...
34
votes
1
answer
19k
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....
34
votes
3
answers
76k
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 ...
33
votes
4
answers
40k
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 ...
33
votes
2
answers
38k
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(...
33
votes
14
answers
25k
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
...
32
votes
4
answers
26k
views
Using plotly without online plotly account
Is it possible to use the plotly library to create charts in python without having an online plotly account? I think the code is opensource https://github.com/plotly/plotly.py. I would like to know ...
32
votes
1
answer
4k
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"...
30
votes
3
answers
42k
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 = "...
30
votes
5
answers
75k
views
Distributed 1.21.8 requires msgpack, which is not installed
I'm having a problem trying to install plotly. I proceeded to upgrade anaconda using the command line on Debian 9 and I received the error message "distributed 1.21.0 requires msgpack, which is not ...
30
votes
1
answer
40k
views
Plotting Pandas Multiindex Bar Chart
How can I plot a Python Pandas multiindex dataframe as a bar chart with group labels? Do any of the plotting libraries directly support this? This SO post shows a custom solution using matplotlib, but ...
30
votes
2
answers
53k
views
Format y-axis as percent in plot.ly
How do I format the y-axis as percent in plot.ly?. in var layout I have the following settings for the y-axis:
yaxis: {
hoverformat: ",.0%"
},
which changes the hover to ...
30
votes
2
answers
57k
views
Changing visibility of a Dash Component by updating other Component
I need to hide some Components, for example by clicking on a checkbox (for example, a graph or a table). However, the documentation did not provide a suitable section for this purpose. Thanks in ...
30
votes
6
answers
47k
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?
30
votes
3
answers
38k
views
Change transparency of fillcolor
I'm trying to change the default color of a fillcolor in Plotly to another transparent one, but when I change the fillcolor it is not transparent anymore.
trace = (go.Scatter(x=[30,45],y=[3000,3000],...
29
votes
1
answer
30k
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....