Im trying to plot a bar plot in plotly that is representing net-gains (will have positive and negative bar values). But somewhat the negative values in the y-axis are being represented in gibberish. I tried several things, including using update_layout
function, but nothing seems to work. Im using the make_subplots
function because i want to plot multiple viz on one figure.
Im using databricks for this code.
Attaching my code and viz output:
net_gains = pd.DataFrame()
net_gains["general_net_gain"] = [-2,2,-1,2]
fig = plotly.subplots.make_subplots(rows=1, cols=1)
fig.add_bar(x=net_gains.index, y=net_gains["general_net_gain"], row=1, col=1)
fig.update_layout(height=400,width=500,showlegend=True)
[![Viz output][1]][1]
AIMPED
January 25, 2023, 9:40pm
2
HI @harrykane welcome to the forums.
I canβt reproduce this and never have seen this before. Did you find a way to solve it?
AIMPED
January 26, 2023, 9:51am
3
Hi, seems that you are not the only one with this issue:
Hi @jmmease this code works really good for me apart from one issue. I see that if I put negative values for x-axis or y-axis, it comes with some absurd prefix like ΓΔΓ^Γβ60 for -60.
Could you please suggest a solution for this.
Thanks
Nitin
[Screenshot 2023-01-26 at 9.18.17 AM]
Which plotly version are you using?
@adamschroeder
@adamschroeder im using 5.12.0 plotly version
hi @harrykane
Iβm not able to recreate your issue either. Iβm using plotly 5.12.0, and Iβve tried this code:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import plotly
fig = plotly.subplots.make_subplots(rows=1, cols=1)
fig.add_bar(x=[1, 2, 3], y=[-4, 5, -6],
row=1, col=1
)
fig.update_layout(height=600, width=800)
fig.show()
which makes this:
Iβve also tried this code:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=1, cols=2)
fig.add_trace(
go.Scatter(x=[1, 2, 3], y=[-4, 5, -6]),
row=1, col=1
)
fig.add_trace(
go.Scatter(x=[20, 30, 40], y=[50, -60, 70]),
row=1, col=2
)
fig.update_layout(height=600, width=800, title_text="Side By Side Subplots")
fig.show()
Can you please share a sample of your data and full code that was used to create the problematic charts.
The following code duplicates the problem for me:
#!/usr/bin/env python3
"""Test negative bug."""
from plotly.subplots import make_subplots
fig = make_subplots(rows=1, cols=1)
fig.add_bar(x=[1, 2, 3], y=[-4, 5, -6], row=1, col=1)
fig.update_layout(height=400, width=500, showlegend=True)
with open('web/negative.html', 'w', encoding='utf-8') as index_file:
index_file.write(fig.to_html(full_html=False))
This results in:
When I change to full_html=True
, it works properly:
This seems to be a recent bug because it worked fine before I upgraded Plotly. Iβm using this version from conda-forge:
plotly 5.13.1 pyhd8ed1ab_0 conda-forge
1 Like