Skip to content

Commit 3e93c6a

Browse files
committed
added a ganged plot example
svn path=/trunk/matplotlib/; revision=257
1 parent b90b5c9 commit 3e93c6a

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

examples/ganged_plots.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Top create plots that share a common axes (visually) you need to set
3+
the axes locations manually by supplying the appropriate axes
4+
rectangles. Normally you'll want to turn off the tick labels on all
5+
but one of the axes.
6+
7+
In this example the plots share a common xaxis but you can follow the
8+
same logic to supply a common y axis.
9+
"""
10+
from matplotlib.matlab import *
11+
12+
t = arange(0.0, 2.0, 0.01)
13+
14+
s1 = sin(2*pi*t)
15+
s2 = exp(-t)
16+
s3 = s1*s2
17+
18+
# axes rect in relative 0,1 coords left, bottom, width, height. Turn
19+
# off xtick labels on all but the lower plot
20+
ax1 = axes([0.1, 0.1, 0.8, 0.25]) # lower
21+
ax2 = axes([0.1, 0.35, 0.8, 0.25]) # middle
22+
ax2.set_xticklabels([])
23+
ax3 = axes([0.1, 0.6, 0.8, 0.25]) # upper
24+
ax3.set_xticklabels([])
25+
26+
ax1.plot(t,s1)
27+
ax2.plot(t,s2)
28+
ax3.plot(t,s3)
29+
30+
show()

examples/image_demo_na.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from matplotlib import rcParams
2+
rcParams['numerix'] = 'numarray'
3+
4+
from matplotlib.matlab import *
5+
6+
7+
def bivariate_normal(X, Y, sigmax=1.0, sigmay=1.0,
8+
mux=0.0, muy=0.0, sigmaxy=0.0):
9+
"""
10+
Bivariate gaussan distribution for equal shape X, Y
11+
12+
http://mathworld.wolfram.com/BivariateNormalDistribution.html
13+
"""
14+
Xmu = X-mux
15+
Ymu = Y-muy
16+
17+
rho = sigmaxy/(sigmax*sigmay)
18+
z = Xmu**2/sigmax**2 + Ymu**2/sigmay - 2*rho*Xmu*Ymu/(sigmax*sigmay)
19+
return 1.0/(2*pi*sigmax*sigmay*(1-rho**2)) * exp( -z/(2*(1-rho**2)))
20+
21+
22+
delta = 0.025
23+
x = arange(-3.0, 3.0, delta)
24+
y = arange(-3.0, 3.0, delta)
25+
X,Y = meshgrid(x, y)
26+
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
27+
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
28+
29+
# difference of Gaussians
30+
im = imshow(Z2-Z1)
31+
32+
# set the interpolation method: 'nearest', 'bilinear', 'bicubic' and much more
33+
im.set_interpolation('bilinear')
34+
35+
36+
axis('off')
37+
#savefig('test')
38+
show()
39+

0 commit comments

Comments
 (0)