Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 316ae24

Browse files
committed
cleaned up some pyplots examples that got funkily duplicated
svn path=/trunk/matplotlib/; revision=5693
1 parent 071cd08 commit 316ae24

2 files changed

Lines changed: 0 additions & 380 deletions

File tree

doc/pyplots/boxplot_demo.py

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -27,119 +27,3 @@
2727
plt.boxplot(data)
2828
plt.show()
2929

30-
import numpy as np
31-
import matplotlib.pyplot as plt
32-
33-
spread = np.random.rand(50) * 100
34-
center = np.ones(25) * 50
35-
flier_high = np.random.rand(10) * 100 + 100
36-
flier_low = np.random.rand(10) * -100
37-
data = np.concatenate((spread, center, flier_high, flier_low), 0)
38-
39-
# fake up some more data
40-
spread = np.random.rand(50) * 100
41-
center = np.ones(25) * 40
42-
flier_high = np.random.rand(10) * 100 + 100
43-
flier_low = np.random.rand(10) * -100
44-
d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
45-
data.shape = (-1, 1)
46-
d2.shape = (-1, 1)
47-
48-
#data = concatenate( (data, d2), 1 )
49-
# Making a 2-D array only works if all the columns are the
50-
# same length. If they are not, then use a list instead.
51-
# This is actually more efficient because boxplot converts
52-
# a 2-D array into a list of vectors internally anyway.
53-
data = [data, d2, d2[::2,0]]
54-
# multiple box plots on one figure
55-
56-
plt.boxplot(data)
57-
plt.show()
58-
59-
import numpy as np
60-
import matplotlib.pyplot as plt
61-
62-
spread = np.random.rand(50) * 100
63-
center = np.ones(25) * 50
64-
flier_high = np.random.rand(10) * 100 + 100
65-
flier_low = np.random.rand(10) * -100
66-
data = np.concatenate((spread, center, flier_high, flier_low), 0)
67-
68-
# fake up some more data
69-
spread = np.random.rand(50) * 100
70-
center = np.ones(25) * 40
71-
flier_high = np.random.rand(10) * 100 + 100
72-
flier_low = np.random.rand(10) * -100
73-
d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
74-
data.shape = (-1, 1)
75-
d2.shape = (-1, 1)
76-
77-
#data = concatenate( (data, d2), 1 )
78-
# Making a 2-D array only works if all the columns are the
79-
# same length. If they are not, then use a list instead.
80-
# This is actually more efficient because boxplot converts
81-
# a 2-D array into a list of vectors internally anyway.
82-
data = [data, d2, d2[::2,0]]
83-
# multiple box plots on one figure
84-
85-
plt.boxplot(data)
86-
plt.show()
87-
88-
import numpy as np
89-
import matplotlib.pyplot as plt
90-
91-
spread = np.random.rand(50) * 100
92-
center = np.ones(25) * 50
93-
flier_high = np.random.rand(10) * 100 + 100
94-
flier_low = np.random.rand(10) * -100
95-
data = np.concatenate((spread, center, flier_high, flier_low), 0)
96-
97-
# fake up some more data
98-
spread = np.random.rand(50) * 100
99-
center = np.ones(25) * 40
100-
flier_high = np.random.rand(10) * 100 + 100
101-
flier_low = np.random.rand(10) * -100
102-
d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
103-
data.shape = (-1, 1)
104-
d2.shape = (-1, 1)
105-
106-
#data = concatenate( (data, d2), 1 )
107-
# Making a 2-D array only works if all the columns are the
108-
# same length. If they are not, then use a list instead.
109-
# This is actually more efficient because boxplot converts
110-
# a 2-D array into a list of vectors internally anyway.
111-
data = [data, d2, d2[::2,0]]
112-
# multiple box plots on one figure
113-
114-
plt.boxplot(data)
115-
plt.show()
116-
117-
import numpy as np
118-
import matplotlib.pyplot as plt
119-
120-
spread = np.random.rand(50) * 100
121-
center = np.ones(25) * 50
122-
flier_high = np.random.rand(10) * 100 + 100
123-
flier_low = np.random.rand(10) * -100
124-
data = np.concatenate((spread, center, flier_high, flier_low), 0)
125-
126-
# fake up some more data
127-
spread = np.random.rand(50) * 100
128-
center = np.ones(25) * 40
129-
flier_high = np.random.rand(10) * 100 + 100
130-
flier_low = np.random.rand(10) * -100
131-
d2 = np.concatenate( (spread, center, flier_high, flier_low), 0 )
132-
data.shape = (-1, 1)
133-
d2.shape = (-1, 1)
134-
135-
#data = concatenate( (data, d2), 1 )
136-
# Making a 2-D array only works if all the columns are the
137-
# same length. If they are not, then use a list instead.
138-
# This is actually more efficient because boxplot converts
139-
# a 2-D array into a list of vectors internally anyway.
140-
data = [data, d2, d2[::2,0]]
141-
# multiple box plots on one figure
142-
143-
plt.boxplot(data)
144-
plt.show()
145-

doc/pyplots/contour_demo.py

Lines changed: 0 additions & 264 deletions
Original file line numberDiff line numberDiff line change
@@ -62,269 +62,5 @@
6262
CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
6363

6464

65-
#savefig('contour_demo')
66-
plt.show()
67-
#!/usr/bin/env python
68-
"""
69-
Illustrate simple contour plotting, contours on an image with
70-
a colorbar for the contours, and labelled contours.
71-
72-
See also contour_image.py.
73-
"""
74-
import matplotlib
75-
import numpy as np
76-
import matplotlib.cm as cm
77-
import matplotlib.mlab as mlab
78-
import matplotlib.pyplot as plt
79-
80-
matplotlib.rcParams['xtick.direction'] = 'out'
81-
matplotlib.rcParams['ytick.direction'] = 'out'
82-
83-
delta = 0.025
84-
x = np.arange(-3.0, 3.0, delta)
85-
y = np.arange(-2.0, 2.0, delta)
86-
X, Y = np.meshgrid(x, y)
87-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
88-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
89-
# difference of Gaussians
90-
Z = 10.0 * (Z2 - Z1)
91-
92-
93-
# You can use a colormap to specify the colors; the default
94-
# colormap will be used for the contour lines
95-
plt.figure()
96-
im = plt.imshow(Z, interpolation='bilinear', origin='lower',
97-
cmap=cm.gray, extent=(-3,3,-2,2))
98-
levels = np.arange(-1.2, 1.6, 0.2)
99-
CS = plt.contour(Z, levels,
100-
origin='lower',
101-
linewidths=2,
102-
extent=(-3,3,-2,2))
103-
104-
#Thicken the zero contour.
105-
zc = CS.collections[6]
106-
plt.setp(zc, linewidth=4)
107-
108-
plt.clabel(CS, levels[1::2], # label every second level
109-
inline=1,
110-
fmt='%1.1f',
111-
fontsize=14)
112-
113-
# make a colorbar for the contour lines
114-
CB = plt.colorbar(CS, shrink=0.8, extend='both')
115-
116-
plt.title('Lines with colorbar')
117-
#plt.hot() # Now change the colormap for the contour lines and colorbar
118-
plt.flag()
119-
120-
# We can still add a colorbar for the image, too.
121-
CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
122-
123-
# This makes the original colorbar look a bit out of place,
124-
# so let's improve its position.
125-
126-
l,b,w,h = plt.gca().get_position().bounds
127-
ll,bb,ww,hh = CB.ax.get_position().bounds
128-
CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
129-
130-
131-
#savefig('contour_demo')
132-
plt.show()
133-
#!/usr/bin/env python
134-
"""
135-
Illustrate simple contour plotting, contours on an image with
136-
a colorbar for the contours, and labelled contours.
137-
138-
See also contour_image.py.
139-
"""
140-
import matplotlib
141-
import numpy as np
142-
import matplotlib.cm as cm
143-
import matplotlib.mlab as mlab
144-
import matplotlib.pyplot as plt
145-
146-
matplotlib.rcParams['xtick.direction'] = 'out'
147-
matplotlib.rcParams['ytick.direction'] = 'out'
148-
149-
delta = 0.025
150-
x = np.arange(-3.0, 3.0, delta)
151-
y = np.arange(-2.0, 2.0, delta)
152-
X, Y = np.meshgrid(x, y)
153-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
154-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
155-
# difference of Gaussians
156-
Z = 10.0 * (Z2 - Z1)
157-
158-
159-
# You can use a colormap to specify the colors; the default
160-
# colormap will be used for the contour lines
161-
plt.figure()
162-
im = plt.imshow(Z, interpolation='bilinear', origin='lower',
163-
cmap=cm.gray, extent=(-3,3,-2,2))
164-
levels = np.arange(-1.2, 1.6, 0.2)
165-
CS = plt.contour(Z, levels,
166-
origin='lower',
167-
linewidths=2,
168-
extent=(-3,3,-2,2))
169-
170-
#Thicken the zero contour.
171-
zc = CS.collections[6]
172-
plt.setp(zc, linewidth=4)
173-
174-
plt.clabel(CS, levels[1::2], # label every second level
175-
inline=1,
176-
fmt='%1.1f',
177-
fontsize=14)
178-
179-
# make a colorbar for the contour lines
180-
CB = plt.colorbar(CS, shrink=0.8, extend='both')
181-
182-
plt.title('Lines with colorbar')
183-
#plt.hot() # Now change the colormap for the contour lines and colorbar
184-
plt.flag()
185-
186-
# We can still add a colorbar for the image, too.
187-
CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
188-
189-
# This makes the original colorbar look a bit out of place,
190-
# so let's improve its position.
191-
192-
l,b,w,h = plt.gca().get_position().bounds
193-
ll,bb,ww,hh = CB.ax.get_position().bounds
194-
CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
195-
196-
197-
#savefig('contour_demo')
198-
plt.show()
199-
#!/usr/bin/env python
200-
"""
201-
Illustrate simple contour plotting, contours on an image with
202-
a colorbar for the contours, and labelled contours.
203-
204-
See also contour_image.py.
205-
"""
206-
import matplotlib
207-
import numpy as np
208-
import matplotlib.cm as cm
209-
import matplotlib.mlab as mlab
210-
import matplotlib.pyplot as plt
211-
212-
matplotlib.rcParams['xtick.direction'] = 'out'
213-
matplotlib.rcParams['ytick.direction'] = 'out'
214-
215-
delta = 0.025
216-
x = np.arange(-3.0, 3.0, delta)
217-
y = np.arange(-2.0, 2.0, delta)
218-
X, Y = np.meshgrid(x, y)
219-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
220-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
221-
# difference of Gaussians
222-
Z = 10.0 * (Z2 - Z1)
223-
224-
225-
# You can use a colormap to specify the colors; the default
226-
# colormap will be used for the contour lines
227-
plt.figure()
228-
im = plt.imshow(Z, interpolation='bilinear', origin='lower',
229-
cmap=cm.gray, extent=(-3,3,-2,2))
230-
levels = np.arange(-1.2, 1.6, 0.2)
231-
CS = plt.contour(Z, levels,
232-
origin='lower',
233-
linewidths=2,
234-
extent=(-3,3,-2,2))
235-
236-
#Thicken the zero contour.
237-
zc = CS.collections[6]
238-
plt.setp(zc, linewidth=4)
239-
240-
plt.clabel(CS, levels[1::2], # label every second level
241-
inline=1,
242-
fmt='%1.1f',
243-
fontsize=14)
244-
245-
# make a colorbar for the contour lines
246-
CB = plt.colorbar(CS, shrink=0.8, extend='both')
247-
248-
plt.title('Lines with colorbar')
249-
#plt.hot() # Now change the colormap for the contour lines and colorbar
250-
plt.flag()
251-
252-
# We can still add a colorbar for the image, too.
253-
CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
254-
255-
# This makes the original colorbar look a bit out of place,
256-
# so let's improve its position.
257-
258-
l,b,w,h = plt.gca().get_position().bounds
259-
ll,bb,ww,hh = CB.ax.get_position().bounds
260-
CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
261-
262-
263-
#savefig('contour_demo')
264-
plt.show()
265-
#!/usr/bin/env python
266-
"""
267-
Illustrate simple contour plotting, contours on an image with
268-
a colorbar for the contours, and labelled contours.
269-
270-
See also contour_image.py.
271-
"""
272-
import matplotlib
273-
import numpy as np
274-
import matplotlib.cm as cm
275-
import matplotlib.mlab as mlab
276-
import matplotlib.pyplot as plt
277-
278-
matplotlib.rcParams['xtick.direction'] = 'out'
279-
matplotlib.rcParams['ytick.direction'] = 'out'
280-
281-
delta = 0.025
282-
x = np.arange(-3.0, 3.0, delta)
283-
y = np.arange(-2.0, 2.0, delta)
284-
X, Y = np.meshgrid(x, y)
285-
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
286-
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
287-
# difference of Gaussians
288-
Z = 10.0 * (Z2 - Z1)
289-
290-
291-
# You can use a colormap to specify the colors; the default
292-
# colormap will be used for the contour lines
293-
plt.figure()
294-
im = plt.imshow(Z, interpolation='bilinear', origin='lower',
295-
cmap=cm.gray, extent=(-3,3,-2,2))
296-
levels = np.arange(-1.2, 1.6, 0.2)
297-
CS = plt.contour(Z, levels,
298-
origin='lower',
299-
linewidths=2,
300-
extent=(-3,3,-2,2))
301-
302-
#Thicken the zero contour.
303-
zc = CS.collections[6]
304-
plt.setp(zc, linewidth=4)
305-
306-
plt.clabel(CS, levels[1::2], # label every second level
307-
inline=1,
308-
fmt='%1.1f',
309-
fontsize=14)
310-
311-
# make a colorbar for the contour lines
312-
CB = plt.colorbar(CS, shrink=0.8, extend='both')
313-
314-
plt.title('Lines with colorbar')
315-
#plt.hot() # Now change the colormap for the contour lines and colorbar
316-
plt.flag()
317-
318-
# We can still add a colorbar for the image, too.
319-
CBI = plt.colorbar(im, orientation='horizontal', shrink=0.8)
320-
321-
# This makes the original colorbar look a bit out of place,
322-
# so let's improve its position.
323-
324-
l,b,w,h = plt.gca().get_position().bounds
325-
ll,bb,ww,hh = CB.ax.get_position().bounds
326-
CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
327-
328-
32965
#savefig('contour_demo')
33066
plt.show()

0 commit comments

Comments
 (0)