简体   繁体   English

如何在PLOTLY直方图中将x轴更改为对数

[英]How to Change x-axis to logarithmic in PLOTLY histogram

How to make x-axis of the following histogram, logarithmic? 如何使以下直方图的x轴为对数?

The following code: 如下代码:

data_list = [1,1,5,5,5,100,100]

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Histogram(x=data_list, nbinsx=100))

import plotly.offline as py
py.init_notebook_mode(connected=False)
py.offline.plot(fig, filename = 'test.html')

Produces typical histogram. 产生典型的直方图。 How can I change the x-axis logarithmic? 如何更改x轴的对数?

I also tried: 我也尝试过:

data_list = [1,1,5,5,5,100,100]

import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Histogram(x=data_list, nbinsx=100))

fig.update_layout(xaxis_type="log")
fig.update_xaxes(tick0=0, dtick=1, range=[0,2.5])

import plotly.offline as py
py.init_notebook_mode(connected=False)
py.offline.plot(fig, filename = 'test.html')

but this will result in non-logarithmic bins, and essentially, the bin at 100 disappears! 但这将导致非对数垃圾箱,并且实际上,位于100的垃圾箱会消失!

As said above in the comments, logarithmic axes are not possible with plotly. 如上面的注释中所述,对数轴不可能进行绘图。 You could try to create bins using numpy and create a bar plot with those. 您可以尝试使用numpy创建垃圾箱,并使用它们创建条形图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM