8000 DOC: sphinx-gallery histograms by choldgraf · Pull Request #8245 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
addressing small change comments
  • Loading branch information
choldgraf authored Mar 10, 2017
commit 77c16fb3175897cae8308a688e30756b4d0647ec
9 changes: 5 additions & 4 deletions examples/statistics/plot_hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# To generate a 1D histogram we only need a single vector of numbers. For a 2D
# histogram we'll need a second vector. We'll generate both below, and show
# the histogram for each vector
# the histogram for each vector.

N_points = 100000
n_bins = 20
Expand All @@ -44,7 +44,7 @@
# The histogram method returns (among other things) a `patches` object. This
# gives us access to the properties of the objects drawn. Using this, we can
# edit the histogram to our liking. Let's change the color of each bar
# based on its y value
# based on its y value.

fig, axs = plt.subplots(1, 2, figsize=(10, 5), tight_layout=True)

Expand All @@ -62,7 +62,7 @@
color = plt.cm.viridis(norm(thisfrac))
thispatch.set_facecolor(color)

# We can also normalize our inputs by the total number of counts.
# We can also normalize our inputs by the total number of counts
axs[1].hist(x, bins=n_bins, normed=True)

# Now we format the y-axis to display percentage
Expand All @@ -79,12 +79,13 @@
fig, ax = plt.subplots(tight_layout=True)
hist = ax.hist2d(x, y)


###############################################################################
# Customizing your histogram
# --------------------------
#
# Customizing a 2D histogram is similar to the 1D case, you can control
# visual components such as the bin size or color normalization
# visual components such as the bin size or color normalization.

fig, axs = plt.subplots(1, 3, figsize=(15, 5), sharex=True, sharey=True,
tight_layout=True)
Expand Down
0