## matplotlib-users

 [Matplotlib-users] Histogram with logarithmic x-axis From: Thomas Robitaille - 2009-08-03 18:49:08 ```Hi, What is the easiest way to plot a histogram with a logarithmic x-axis? The Axes.hist() method takes a log=True/False argument, but this applies only to the y axis. Is the only solution to plot a histogram of np.log10(array) and to change the tick formatter to a Log formatter, or is there a more straightforward way? Thanks, Tom -- View this message in context: http://www.nabble.com/Histogram-with-logarithmic-x-axis-tp24796094p24796094.html Sent from the matplotlib - users mailing list archive at Nabble.com. ```
 Re: [Matplotlib-users] Histogram with logarithmic x-axis From: Matthias Michler - 2009-08-05 15:38:44 ```On Monday 03 August 2009 20:48:52 Thomas Robitaille wrote: > Hi, > > What is the easiest way to plot a histogram with a logarithmic x-axis? The > Axes.hist() method takes a log=True/False argument, but this applies only > to the y axis. > > Is the only solution to plot a histogram of np.log10(array) and to change > the tick formatter to a Log formatter, or is there a more straightforward > way? > > Thanks, > > Tom Hi Tom, I'm not sure I understood correctly, but maybe the attached example goes towards a solution ... best regards Matthias ######################### import numpy as np import matplotlib.pyplot as plt # generate some data on log-scale x = 10**np.random.uniform(size=1000) # histogram with log-bining plt.hist(x, bins=10**np.linspace(0, 1, 10)) plt.xscale('log') plt.show() ############################## ```
 Re: [Matplotlib-users] Histogram with logarithmic x-axis From: Thomas Robitaille - 2009-08-05 16:09:46 ``` Matthias Michler wrote: > > > ######################### > import numpy as np > import matplotlib.pyplot as plt > > # generate some data on log-scale > x = 10**np.random.uniform(size=1000) > # histogram with log-bining > plt.hist(x, bins=10**np.linspace(0, 1, 10)) > plt.xscale('log') > plt.show() > ############################## > > Hi Matthias, This is exactly what I need - I did not know about the xscale function. Thanks! Tom -- View this message in context: http://www.nabble.com/Histogram-with-logarithmic-x-axis-tp24796094p24831570.html Sent from the matplotlib - users mailing list archive at Nabble.com. ```