Questions tagged [plotly-python]
Use this tag for questions about the interactive graphing library for Python.
2,113
questions
-1
votes
3
answers
72
views
How to create a custom sort for a list of strings
I'm working to create some visualizations and I've got some decent ones going with Plotly, and technically my plots are working. However, I've got a variable that I'm using as an axis for a couple ...
0
votes
0
answers
24
views
Plotly with ipywidgets creates multiple plots in VS Code instead of updating the already existing plot
import plotly.graph_objs as go
import ipywidgets as widgets
import numpy as np
# Create some data for the plots
x = np.random.rand(50)
y = np.random.rand(50)
# Create a function that will be called ...
1
vote
0
answers
24
views
How to add fullscreen icon to a plotly chart modebar in Python Dash App
I am trying to add fullscreen option in plotly modebar to all my plotly's chart in a python Dash app. I've seen a lot of custom code snippets to achieve it in R ou JS. However, I can't find something ...
0
votes
1
answer
27
views
How to move the legend of each trace inside each subplot when subplot has more than 1 column
When subplot has 2 columns and 2 rows. Typically the legends are grouped together and places on the same location like below on the right hand side. I am wondering if I can place legend of each trace ...
0
votes
0
answers
13
views
in plotly, how to change colors with css variables?
I would like to be able to change colors with css variables so that when other parts of my React code changes that css variable dynamically, it should reflect the change inside of plotly frame as well....
0
votes
0
answers
9
views
How can I use the colors I want in a plot with different categories?
I have the following script
import plotly.express as px
import pandas as pd
# Your data
data = {
'X': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
'Y': [5, 4, 3, 2, 1, 2, 3, 4, 5, 5],
'Cat': ["...
1
vote
1
answer
24
views
Control duplication of legend items in Python Plotly.express
I am using plotly.express to produce a figure with 3 subplots. The legend repeats for each subplot, so I have 3 legend listings (one for each subplot) for each item. All operate together when I click ...
0
votes
2
answers
78
views
passing value from callback to callback in Plotly dash application
i have a dash application with a plotly graph i have two callbacks i want to get input from the user store it with dcc.store in the variable with id 'stkName-value' and call it in the other callback. ...
0
votes
1
answer
33
views
How can I make a histogram with two consecutive bars in plotly?
I have the following code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Sample data (replace this with your actual DataFrame)
data = {
'CU': [1.5, 2.3, 1.8, 3.2, 2.5, 2....
1
vote
2
answers
62
views
Plot with colors depending on data
I would like to plot some data but with colors depending on certain conditions. Ideally I would like to do it in both plotly and matplotlib (separate scripts)
The data
For example I have the following ...
0
votes
1
answer
68
views
How to create a 3D scatter plot with plotly with all markers individually colored?
Following the suggestion HERE I have tried the following code to create a Scatter3D plot with plotly in a jupyter notebook so each marker is colored individually, like you can do with matplotlib and ...
0
votes
0
answers
11
views
in jsgantt-improved, all cols in left data table is not visible to users
I am using jsgantt-improved in plotly dash to display the gantt-chart with data table.
this is my output
left data table is not displaying all the columns.
this is my
json=[
{
"pID": 1,
&...
0
votes
0
answers
29
views
How to add a second toImageButton
In a python interactive plot using Plotly with the hoverable legend at the top: I would like to add a second toImageButton which downloads the plot as .svg (marked in orange) in addition to the button ...
-1
votes
0
answers
9
views
Clustering or accumulations of big LINESTRING geodata
I have a big LINESTRING geodata for buildings which as nearly 30,000 rows. When I tried to plot with plotly (go.Scattermapbox) by creating trace and layout, it doesnt show anything on the map because ...
0
votes
1
answer
62
views
How to format bar chart yearly x-axis to not contain floats
What causes the x-axis to have Year numbers in between the bars and the 0.5 attached to the Population Year
ru = px.bar(wakel, x = "Population Year", y = "Population", color = &...
0
votes
0
answers
26
views
Plotly dot plot - how to group multiple columns
I feel like I'm going crazy trying to figure this out. Supposedly I have this data frame, how can I create a dot plot similar to the graph below? (just the dots and not the bars)
ProbesetID
bone ...
0
votes
0
answers
12
views
Plotly figure_factory create_ternary_contour is ignoring my negative values
I am trying to create a ternary contour plot. I have a dataframe; I will reproduce a small portion of it here to show what the data looks like and verify that some of the values are significantly ...
1
vote
1
answer
58
views
Problem with animation of multiple traces with plotly
I'm trying to animate multiple tracks with Python plotly.
The code is:
import pandas as pd
import plotly.express as px
df = pd.read_csv("orbite.csv")
fig=px.scatter(df,x="X1",y=&...
2
votes
1
answer
37
views
Add next/previous buttons to plotly dash
The dash app has mainly two plots, of which the first one is used to show data in the second one. This is by selecting a data point in the first and it will load up a connected data frame to be shown ...
-1
votes
1
answer
15
views
I am not getting the correct Box visualization when using plotly.graph_objects.Box() function
I am using 4 datasets, which are very identical (example data head given below). I am using plotly graph_objects Box function together with make_subplots function to create the box plots. Below is the ...
1
vote
1
answer
33
views
Order plotly figure by CategoricalDtype order
The goal is to visualize boxplots for each group in order. Group is ofpd.CategoricalDtype and ordered.
I do not manage to get plotly to respect the order. Instead, it only sorts alphabetically.
import ...
0
votes
0
answers
15
views
Hover info within a selection in Plotly
When selecting a set of points in a plotly scatter plot, the displaying of hover data is disabled.
This behavior can very well be observed in any of the examples in the plotly selection doc.
Using ...
0
votes
1
answer
51
views
Custom color for plotly python radar chart labels
I want to colorize each label_column with label_color using fig.update_polars(angularaxis_color=color) or fig.update_polars(angularaxis=dict(color=color)) but I can't.
How can I color each ...
0
votes
0
answers
14
views
is there a way to display a plot using hover template in plotly?
I want to display a plot B on hovering over a point in scatter plot A. Can I do this using plotly?
I tried to enter the pie plot B as a hover template attribute but it does not work. Is plotly the ...
0
votes
1
answer
19
views
plotly fig stopped to output chart in Jupyter
import plotly.express as px
print(f"{df.to_pandas()['decrease_percentage']}")
outputs
0 -0.01
1 0.00
2 -0.01
3 0.00
4 0.00
...
299295 0....
0
votes
0
answers
19
views
plotly sunburst + datapane : bug with markers shape
I have sunburst figure made with plotly that I'd like to include into a datapane report. However, some of the levels are hatched, and the hatching is not displayed in datapane (works fine in a ...
-1
votes
0
answers
24
views
Plotly : Strange behavior of add_annotation
I use patly express to plot a choropeth map from geojson file and want to add annotations.
When I add the first one, it works perfectly. But, when it comes to the second, it changes axes for all ...
-1
votes
1
answer
58
views
Secondary Axis Range from 0 to None in Update Layout Not Working
I have a data of total sales and total invoices (rows) per Year. I want to plot them in a bar and line chart. I successfully made the chart with plotly.
However I am having problem in adjusting the ...
0
votes
0
answers
19
views
How can I make the Y axis of a subplot synchronize but keep their labels separated?
In plotly if you have this script
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(
rows=1, cols=2, subplot_titles=("Plot 1", "...
0
votes
1
answer
40
views
How do I make interacting updates?
The Plotly Documentation on Dropdowns contains the following example:
import plotly.graph_objects as go
import pandas as pd
# Load dataset
df = pd.read_csv(
"https://raw.githubusercontent....
1
vote
1
answer
45
views
Why nan values appear on plotly heatmap?
I have the following script
import plotly.graph_objects as go
X = [0.001872507, 0.001873447, 0.001874379, 0.001875308, 0.001876231, 0.001877156, 0.001878074, 0.001878988, 0.001879891, 0.00188079]
Y = ...
0
votes
1
answer
28
views
Why my heatmap is plotting nans if I expressly extracted the nans?
I have this piece of code
print(abs(data.left_error))
print(data['left_error'].isna().sum())
# Remove rows with NaN values in the 'left_error' column
left_no_nan = data.dropna(subset=[...
0
votes
0
answers
26
views
The choropleth map and slider do not show the same date
I have a dataframe with countries, years and the country code.
Each additional column, such as "Annual CO2 Emission" can have a different start date in which data is available.
However, my ...
1
vote
0
answers
24
views
Plotly Error: X-axis of scatter is grouping time series points erroneously
TL;DR
I am plotting time series data using a plotly scatter plot in a streamlit dashboard. The data is captured every second (actually down to microseconds) but the plot groups approximately every two ...
1
vote
1
answer
48
views
Display text outside of a trace not working
I am trying to display percentages outside of the bottom (dark orange) trace on my graph.
Here is my code:
bar2 = go.Figure()
bar2.add_trace(go.Bar(name = 'Halted Trials',
x = ...
0
votes
0
answers
35
views
how to have colors that depends on the value of a column in plotly?
I a using plotly python and I would like to have a graph with colours that depends of the value of my dataframe column.
My code is as follows:
fig = go.Figure(data=go.Scatter(x=Rdt_risque['Risque'],
...
0
votes
0
answers
15
views
Combining stacked bar charts with same x axis in plotly
Lets say I have a dataframe with categorical columns A,B,C and a continuous column D.
I have plotted two stacked bars, one where the categories of A are along the x axis and the categories of B are ...
0
votes
1
answer
37
views
Python Plotly: I want to force plotly to connect gaps between lines in a Line Chart
I have this dataframe. It shows a football player, his club and his overall each year from 2017 to 2023
Dataframe
The initial idea was to make this line chart, showing the year in X Axis and Overall ...
0
votes
0
answers
14
views
Can a dash plot extend below the height of the page (perhaps using scrolling)?
I have this script of plotting using dash (the slider in the top does not work- no problem)
import dash
from dash import dcc, html
from dash.dependencies import Input, Output
import pandas as pd
...
1
vote
1
answer
31
views
How to draw 3d histograms in plotly?
I am looking to re-create the multi-histogram visualization available in tensorboard using plotly:
The plotting of the individual histograms is trivial, but I don't know how to 3d offset the traces.
...
1
vote
1
answer
56
views
Plotly Express: How can I adjust the size of marginal distribution plots?
I have several datasets I am plotting with plotly express's scatterplot. I am using the option of the marginal distribution plots to show a histogram of the datasets but the problem is that the ...
0
votes
1
answer
25
views
Increase line width in Plotly Scattergeo
I have a set of coordinates and I want to use them to draw a path on a map using Plotly. But I don't understand how to increase the width of the lines.
What I've tried:
import plotly.graph_objects as ...
0
votes
0
answers
38
views
How to achieve spacing in between specific subplots using plotly express dash- Python
For my webapp, I have 6 plotly line subplots arranged in 6 rows and 1 column with shared x-axis. I am able to plot all the 6 subplots either without spaces between them or having same spacing between ...
2
votes
1
answer
92
views
How to create html plots which dynamically adjust marker size when zooming
I've created a Python script that generates a bar chart using Matplotlib and converts it into an interactive HTML graphic using mpld3. The chart displays average hashing times for different algorithms ...
0
votes
0
answers
29
views
Plotly rotate animation in Python to HTML file
I am trying to animate a 3D scatterplot in Plotly being rotated around an axis and save the output as html.
The only resource I found is done in R.
Wondering if anyone has any resources on doing it in ...
0
votes
2
answers
75
views
Use Plotly to show multiple lines by value of another column in the dataframe
I have a dataframe that looks like this:
fruit number date
apple 7 2013-11-4
banana 8 2016-4-6
apple 2 2018-7-22
banana 103 2020-4-4
I want a line plot with two lines: the ...
0
votes
0
answers
46
views
Reducing memory consumption of Plotly graphs with Dash
I am using Dash and have Plotly to display 3D-mesh diagrams, sometimes having necessary to show 5 diagrams at the same time.
This causes a lot of memory build-up when I inspect the webpage and I ...
1
vote
1
answer
40
views
Python Plotly Planes Perpendicular to Axes in 3D Plot
I could not draw the plane x=y in plotly using python.
My code to generate points on a plane given its normal vector and some point contained in it. What I do is generating two orthonormal vectors ...
0
votes
1
answer
50
views
fig.show() doesn't show the plot when using Candlestick [duplicate]
I have trouble to show the candlestick plot. I have tried fig.show() and iplot(fig) but they return a white screen! and when I try plt.plot(fig) I get TypeError: unhashable type: 'Figure'.
here is the ...
0
votes
1
answer
59
views
Filter data in long format using dropdown menu with plotly
I am trying to filter data, which is in a long format, using dropdown menu in plotly. However, I might be misunderstanding something as I am not getting the proper results. I want to combine this with ...