[英]How to increase x ticks in plotly.express histogram
I have a Plotly graph with code:我有一个带有代码的 Plotly 图:
import plotly.express as px
fig = px.histogram(df.col1, width= 1500, height= 700)
fig.show()
and the plot looks like this: plot 看起来像这样:
Tried:试过:
import plotly.express as px
fig = px.histogram(df.col1, width= 1500, height= 700)
fig.update_traces(xbins_size = 0.5)
fig.show()
The issue is that I would like to increase x ticks to every 5 to improve visibility while capturing the range of 0-50.问题是我想将 x 刻度增加到每 5 次以提高可见性,同时捕获 0-50 的范围。 But the interval is still 10.
但是间隔仍然是10。
fig.update_traces(xbins_size = <float>)
For a plot built with:对于使用以下组件构建的 plot:
fig = px.histogram(x=np.random.randn(500))
You can use:您可以使用:
fig.update_traces(xbins_size = 0.5)
And get:并得到:
Now, compare this with:现在,将其与以下内容进行比较:
fig.update_traces(xbins_size = 1)
Which will give you:这会给你:
import plotly.express as px
import numpy as np
np.random.seed(123)
fig = px.histogram(x=np.random.randn(500))
fig.update_traces(xbins_size = 0.5)
fig.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.