Skip to content

Commit

Permalink
nonuniform images, scipy and setup
Browse files Browse the repository at this point in the history
svn path=/trunk/matplotlib/; revision=1898
  • Loading branch information
jdh2358 committed Dec 3, 2005
1 parent 569a946 commit 0c97190
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 67 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
2005-12-01 Applied Alex Gontmakher hatch patch - PS only for now
2005-12-03 Modified setup to build matplotlibrc based on compile time
findings. It will set numerix in the order of scipy,
numarray, Numeric depending on which are founds, and
backend as in preference order GTKAgg, WXAgg, TkAgg, GTK,
Agg, PS

2005-12-03 Modified scipy patch to support Numeric, scipy and numarray
Some work remains to be done because some of the scipy
imports are broken if only the core is installed. Eg
apparently we need from scipy.basic.fftpack import * rather
than from scipy.fftpack import *

2005-12-03 Applied some fixes to Nicholas Young's nonuniform image
patch

2005-12-01 Applied Alex Gontmakher hatch patch - PS only for now

2005-11-30 Added Rob McMullen's EMF patch
h
Expand Down
26 changes: 26 additions & 0 deletions examples/pcolor_nonuniform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from pylab import figure, show
import matplotlib.numerix as nx
from matplotlib.image import NonUniformImage

x = nx.arange(-4, 4, 0.005)
y = nx.arange(-4, 4, 0.005)
print 'Size %d points' % (len(x) * len(y))
z = nx.sqrt(x[nx.NewAxis,:]**2 + y[:,nx.NewAxis]**2)

fig = figure()
ax = fig.add_subplot(111)
im = NonUniformImage(ax, extent=(-4,4,-4,4))
im.set_data(x, y, z)
ax.images.append(im)
ax.set_xlim(-4,4)
ax.set_ylim(-4,4)

fig2 = figure()
ax = fig2.add_subplot(111)
x2 = x**3
im = NonUniformImage(ax, extent=(-64,64,-4,4))
im.set_data(x2, y, z)
ax.images.append(im)
ax.set_xlim(-64,64)
ax.set_ylim(-4,4)
show()
5 changes: 4 additions & 1 deletion lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,18 @@ def set_filterrad(self, filterrad):

def get_filterrad(self):
'return the filterrad setting'
return self._filterrad


class NonUniformImage(AxesImage):
def __init__(self, ax,
cmap = None,
norm = None,
extent=None,
):
AxesImage.__init__(self, ax,
cmap = cmap,
norm = norm,
extent=extent,
aspect = 'free',
interpolation = 'nearest',
origin = 'lower',
Expand Down Expand Up @@ -422,6 +424,7 @@ def set_cmap(self, cmap):




class FigureImage(Artist, cm.ScalarMappable):
def __init__(self, fig,
cmap = None,
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/numerix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def byteswapped(a):
return a.byteswapped()
def itemsize(a):
return a.itemsize()
def resize(a, shape):
return a.resize(shape)

else:
# We've already checked for a valid numerix selector,
# so assume scipy.
Expand Down
2 changes: 1 addition & 1 deletion matplotlibrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg
# Agg Cairo GD GDK Paint PS SVG Template
backend : GTKAgg
numerix : Numeric # Numeric or numarray
numerix : scipy # Numeric or numarray
interactive : False # see http://matplotlib.sourceforge.net/interactive.html
toolbar : toolbar2 # None | classic | toolbar2
timezone : UTC # a pytz timezone string, eg US/Central or Europe/Paris
Expand Down
55 changes: 41 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
respectively; set them to 0 if you do not want to build them
"""


rc = dict(backend='PS', numerix='Numeric')

# build the image support module - requires agg and Numeric or
# numarray. You can build the image module with either Numeric or
# numarray or both. By default, matplotlib will build support for
Expand Down Expand Up @@ -93,9 +96,11 @@
# Figure out which array packages to provide binary support for
# and append to the NUMERIX list.
NUMERIX = []

try:
import Numeric
NUMERIX.append('Numeric')

except ImportError:
pass
try:
Expand All @@ -111,7 +116,10 @@
pass

if not NUMERIX:
raise RuntimeError("You must install Numeric, numarray, or both to build matplotlib")
raise RuntimeError("You must install the new scipy, Numeric, numarray, or both to build matplotlib")


rc['numerix'] = NUMERIX[-1]

# This print interers with --version, which license depends on
#print "Compiling matplotlib for:", NUMERIX
Expand Down Expand Up @@ -181,26 +189,16 @@ def add_dateutil():

if BUILD_GTK:
build_gdk(ext_modules, packages, NUMERIX)

if BUILD_GTKAGG:
try:
import gtk
except ImportError:
print 'GTKAgg requires pygtk'
BUILD_GTKAGG=0
except RuntimeError:
print 'pygtk present but import failed'
if BUILD_GTKAGG:
BUILD_AGG = 1
build_gtkagg(ext_modules, packages, NUMERIX)
rc['backend'] = 'GTK'

if BUILD_TKAGG:
try: import Tkinter
except ImportError: print 'TKAgg requires TkInter'
else:
BUILD_AGG = 1
build_tkagg(ext_modules, packages, NUMERIX)

rc['backend'] = 'TkAgg'

if BUILD_WXAGG:
try: import wxPython
except ImportError:
Expand All @@ -212,9 +210,27 @@ def add_dateutil():
build_wxagg(ext_modules, packages, NUMERIX,
not (isinstance(BUILD_WXAGG, str) # don't about if BUILD_WXAGG
and BUILD_WXAGG.lower() == 'auto')) # is "auto"
rc['backend'] = 'WXAgg'

if BUILD_GTKAGG:
try:
import gtk
except ImportError:
print 'GTKAgg requires pygtk'
BUILD_GTKAGG=0
except RuntimeError:
print 'pygtk present but import failed'

if BUILD_GTKAGG:
BUILD_AGG = 1
build_gtkagg(ext_modules, packages, NUMERIX)
rc['backend'] = 'GTKAgg'

if BUILD_AGG:
build_agg(ext_modules, packages, NUMERIX)
if rc['backend'] == 'PS': rc['backend'] = 'Agg'



if BUILD_FT2FONT:
build_ft2font(ext_modules, packages)
Expand All @@ -232,6 +248,17 @@ def add_dateutil():
if VERBOSE:
mod.extra_compile_args.append('-DVERBOSE')



# packagers: set rc['numerix'] and rc['backend'] here to override the auto
# defaults, eg
#rc['numerix'] = scipy
#rc['backend'] = GTKAgg
template = file('matplotlibrc.template').read()
file('matplotlibrc', 'w').write(template%rc)



setup(name="matplotlib",
version= __version__,
description = "Matlab(TM) style python plotting package",
Expand Down
Loading

0 comments on commit 0c97190

Please sign in to comment.