Today small for everyone to share the use of a python on the plt.hist Detailed parameters, a good reference value, we want to help. Xiao Bian together to follow up to see it
as follows:
matplotlib.pyplot.hist(
x, bins=10, range=None, normed=False,
weights=None, cumulative=False, bottom=None,
histtype=u'bar', align=u'mid', orientation=u'vertical',
rwidth=None, log=False, color=None, label=None, stacked=False,
hold=None, **kwargs)
x : (n,) array or sequence of (n,) arrays
This parameter is specified for each bin (bin) of data distribution, corresponding to the x-axis
bins : integer or array_like, optional
This parameter specifies the number of bin (box), i.e. a total of a few bar chart
normed : boolean, optional
If True, the first element of the return tuple will be the counts normalized to form a probability density, i.e.,n/(len(x)`dbin)
This parameter specifies the density, that is, each bar graph proportion ratio, the default is 1
color : color or array_like of colors or None, optional
The specified color bar chart
We draw a bar chart the distribution of 10,000 data, a total of 50 parts, based on the statistical distribution of 10,000 points
"""
Demo of the histogram (hist) function with a few features.
In addition to the basic histogram, this demo shows a few optional features:
* Setting the number of data bins
* The ``normed`` flag, which normalizes bin heights so that the integral of
the histogram is 1. The resulting histogram is a probability density.
* Setting the face color of the bars
* Setting the opacity (alpha value).
"""
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
# example data
mu = 100 # mean of distribution
sigma = 15 # standard deviation of distribution
x = mu + sigma * np.random.randn(10000)
num_bins = 50
# the histogram of the data
n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='blue', alpha=0.5)
# add a 'best fit' line
y = mlab.normpdf(bins, mu, sigma)
plt.plot(bins, y, 'r--')
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')
# Tweak spacing to prevent clipping of ylabel
plt.subplots_adjust(left=0.15)
plt.show()
More than this about the use python in plt.hist Detailed parameters is small series to share the entire contents of all of the
final was good for everyone to recommend a number of public institutions [programmers], there are a lot of old-timers learning skills, learning tips, interview skills, workplace experience and other share, the more we carefully prepared the zero-based introductory information, information on actual projects, the timing has to explain the Python programmer technology every day, share some learning methods and the need to pay attention to small details