简体   繁体   中英

How to Change x-axis to logarithmic in PLOTLY histogram

How to make x-axis of the following histogram, logarithmic?

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?

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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