Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MEP12: Example clean-up for reference#2474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pelson merged 21 commits intomatplotlib:masterfromtonysyu:canonical-example-refactor
Jan 14, 2014
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
21 commits
Select commitHold shift + click to select a range
8bec412
Remove she-bang line.
tonysyuSep 29, 2013
c25ef1e
Use consistent imports
tonysyuSep 29, 2013
7a59f9f
Remove unnecessary code comments.
tonysyuSep 29, 2013
83dd0ea
Remove unnecessary calls to `show`
tonysyuSep 29, 2013
ece3c57
Rmove unused variable
tonysyuSep 29, 2013
5099675
Split up hist examples into two sections.
tonysyuSep 29, 2013
768500d
Remove use of `setp` in favor of keyword args.
tonysyuSep 29, 2013
44a577b
Replace multiple figures with subplots
tonysyuSep 29, 2013
c80897d
Change bin edges to make the example clearer.
tonysyuSep 29, 2013
bd2b13c
Add titles to clarify intent
tonysyuSep 29, 2013
24aab97
Simplify example
tonysyuSep 29, 2013
fc2ab07
Split demo that tried to do too much
tonysyuSep 29, 2013
e57b5fc
Remove unnecessary second histogram
tonysyuSep 29, 2013
1458aa8
Remove unnecessary parameters
tonysyuSep 29, 2013
c3cce1c
PEP8 fixes
tonysyuSep 29, 2013
6d1b8a2
Add example docstrings
tonysyuSep 29, 2013
f7b2217
Simplify example.
tonysyuSep 29, 2013
a2b5dcd
Clarify title of plot
tonysyuSep 29, 2013
e62e51e
Move histogram examples to statistics directory
tonysyuSep 29, 2013
2dc9a46
Fix example links.
tonysyuSep 29, 2013
ef51dc3
Shorten color names for better gallery build
tonysyuSep 29, 2013
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
PrevPrevious commit
NextNext commit
Split up hist examples into two sections.
The original example was trying to do too much in one place.
  • Loading branch information
@tonysyu
tonysyu committedSep 29, 2013
commit509967518ce5ce5ba31edf12486ffaa344e748f2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.mlab import normpdf
Expand DownExpand Up@@ -48,38 +49,4 @@
plt.grid(True)
plt.ylim(0, 1.05)


plt.figure()

x = mu + sigma*np.random.randn(1000,3)

n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar',
color=['crimson', 'burlywood', 'chartreuse'],
label=['Crimson', 'Burlywood', 'Chartreuse'])
plt.legend()


plt.figure()
n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True)

plt.figure()
n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True)

# Make a multiple-histogram of data-sets with different length.
x0 = mu + sigma*np.random.randn(10000)
x1 = mu + sigma*np.random.randn(7000)
x2 = mu + sigma*np.random.randn(3000)

w0 = np.ones_like(x0)
w0[:len(x0)/2] = 0.5
w1 = np.ones_like(x1)
w1[:len(x1)/2] = 0.5
w2 = np.ones_like(x2)
w2[:len(x2)/2] = 0.5


plt.figure()

n, bins, patches = plt.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar')

plt.show()
39 changes: 39 additions & 0 deletionsexamples/pylab_examples/histogram_demo_multihist.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
import numpy as np
import matplotlib.pyplot as plt


mu, sigma = 200, 25
plt.figure()

x = mu + sigma*np.random.randn(1000,3)

n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar',
color=['crimson', 'burlywood', 'chartreuse'],
label=['Crimson', 'Burlywood', 'Chartreuse'])
plt.legend()


plt.figure()
n, bins, patches = plt.hist(x, 10, normed=1, histtype='bar', stacked=True)

plt.figure()
n, bins, patches = plt.hist(x, 10, histtype='step', stacked=True, fill=True)

# Make a multiple-histogram of data-sets with different length.
x0 = mu + sigma*np.random.randn(10000)
x1 = mu + sigma*np.random.randn(7000)
x2 = mu + sigma*np.random.randn(3000)

w0 = np.ones_like(x0)
w0[:len(x0)/2] = 0.5
w1 = np.ones_like(x1)
w1[:len(x1)/2] = 0.5
w2 = np.ones_like(x2)
w2[:len(x2)/2] = 0.5


plt.figure()

n, bins, patches = plt.hist( [x0,x1,x2], 10, weights=[w0, w1, w2], histtype='bar')

plt.show()

[8]ページ先頭

©2009-2025 Movatter.jp