Skip to content

Commit

Permalink
added a ganged plot example
Browse files Browse the repository at this point in the history
svn path=/trunk/matplotlib/; revision=257
  • Loading branch information
jdh2358 committed Apr 26, 2004
1 parent b90b5c9 commit 3e93c6a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/ganged_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Top create plots that share a common axes (visually) you need to set
the axes locations manually by supplying the appropriate axes
rectangles. Normally you'll want to turn off the tick labels on all
but one of the axes.
In this example the plots share a common xaxis but you can follow the
same logic to supply a common y axis.
"""
from matplotlib.matlab import *

t = arange(0.0, 2.0, 0.01)

s1 = sin(2*pi*t)
s2 = exp(-t)
s3 = s1*s2

# axes rect in relative 0,1 coords left, bottom, width, height. Turn
# off xtick labels on all but the lower plot
ax1 = axes([0.1, 0.1, 0.8, 0.25]) # lower
ax2 = axes([0.1, 0.35, 0.8, 0.25]) # middle
ax2.set_xticklabels([])
ax3 = axes([0.1, 0.6, 0.8, 0.25]) # upper
ax3.set_xticklabels([])

ax1.plot(t,s1)
ax2.plot(t,s2)
ax3.plot(t,s3)

show()
39 changes: 39 additions & 0 deletions examples/image_demo_na.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from matplotlib import rcParams
rcParams['numerix'] = 'numarray'

from matplotlib.matlab import *


def bivariate_normal(X, Y, sigmax=1.0, sigmay=1.0,
mux=0.0, muy=0.0, sigmaxy=0.0):
"""
Bivariate gaussan distribution for equal shape X, Y
http://mathworld.wolfram.com/BivariateNormalDistribution.html
"""
Xmu = X-mux
Ymu = Y-muy

rho = sigmaxy/(sigmax*sigmay)
z = Xmu**2/sigmax**2 + Ymu**2/sigmay - 2*rho*Xmu*Ymu/(sigmax*sigmay)
return 1.0/(2*pi*sigmax*sigmay*(1-rho**2)) * exp( -z/(2*(1-rho**2)))


delta = 0.025
x = arange(-3.0, 3.0, delta)
y = arange(-3.0, 3.0, delta)
X,Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)

# difference of Gaussians
im = imshow(Z2-Z1)

# set the interpolation method: 'nearest', 'bilinear', 'bicubic' and much more
im.set_interpolation('bilinear')


axis('off')
#savefig('test')
show()

0 comments on commit 3e93c6a

Please sign in to comment.