I have a plot with a y axis
It should only show integer values such as 1,2,3,4
Unfortunately when I zoom in floats are displayed (1.5,2.5,3.5)
Is there a way of telling plotly to only display ints
I tried using a list of predefined tickvals but this list is too long when zoomed out fully than the labels overlap
Thanks
This is nice but it produces multiple numbers which are the same.
β1 1.5 2β turns into β1 1 2β
Ideally I was looking for a method of turning β1 1.5 2β into just β1 2β
Thanks
Thereβs probably a way to do this. You can play around with all the possible format settings on http://bl.ocks.org/zanarmstrong/05c1e95bf7aa16c4768e
Thanks etienne your recommeded link worked very well
The format that removes rounded ints was d3.format(",d")
The graph looks much nicer now
In python, along:
fig = Figure(
data = data,
layout = Layout(
barmode='stack',
yaxis={'tickformat': ',d'},
This is an old but interesting point. However, the proposed solution is still giving me multiple numbers in a colorbar. Iβm setting:
colorbar = dict(title=f"{report['unit'][graph]}",
outlinewidth=0.5,
outlinecolor='black',
len=0.7,
thickness=0.02,
thicknessmode='fraction',
ticks='inside',
tickformat=',d',
yanchor='bottom',
y=-0.025)
and the colorbar looks like:
Hello,
Were you guys able to solve this error? Even I am facing the same issues. for eg: Instead of 1, 1.5,2,2.5 converting to 1,2, it gets displayed as 1,1,2,2.
Also if I try to set the dtick as 1, it wont work for the plots which actually has large data.
Thanks
Mit
Iβm having the same issue here. Is there really not a way to set a minimum axis interval?
EDIT: I just noticed that this post is marked with plotly JS. I think the proposed solution should work in JS also, thatβs why I decided to not delete it
Hi,
you could fix the tickvals to integers:
import plotly.graph_objects as go
import numpy as np
def data():
return np.random.uniform(5,10,1000)
x = data()
y = data()
fig = go.Figure(
data=[
go.Scatter(
x=x,
y=y,
mode='markers',
marker={
'color': y,
'colorscale': 'viridis',
'colorbar': {'thickness': 10, 'tickformat': '.1f'},
#'colorbar': {'thickness': 10}
},
showlegend=False,
)
]
)
fig.update_layout(
xaxis={
'range': [y.min(), y.max()],
'tickvals': [*range(int(y.min()), int(y.max())+2)]
},
width=500,
height=500
)
creates: