File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22"""
33pcolormesh uses a QuadMesh, a faster generalization of pcolor, but
44with some restrictions.
5+
6+ This demo illustrates a bug in quadmesh with masked data.
57"""
68
7- import numpy as nx
8- from pylab import figure ,show
9+ import numpy as npy
10+ from matplotlib . pyplot import figure , show
911from matplotlib import cm , colors
12+ from matplotlib .numerix import npyma as ma
1013
1114n = 56
12- x = nx .linspace (- 1.5 ,1.5 ,n )
13- X ,Y = nx .meshgrid (x ,x );
14- Qx = nx .cos (Y ) - nx .cos (X )
15- Qz = nx .sin (Y ) + nx .sin (X )
15+ x = npy .linspace (- 1.5 ,1.5 ,n )
16+ X ,Y = npy .meshgrid (x ,x );
17+ Qx = npy .cos (Y ) - npy .cos (X )
18+ Qz = npy .sin (Y ) + npy .sin (X )
1619Qx = (Qx + 1.1 )
17- Z = nx .sqrt (X ** 2 + Y ** 2 )/ 5 ;
18- Z = (Z - nx . amin ( Z )) / (nx . amax ( Z ) - nx . amin ( Z ))
20+ Z = npy .sqrt (X ** 2 + Y ** 2 )/ 5 ;
21+ Z = (Z - Z . min ( )) / (Z . max ( ) - Z . min ( ))
1922
2023# The color array can include masked values:
21- Zm = nx . ma .masked_where (nx .fabs (Qz ) < 0.5 * nx .amax (Qz ), Z )
24+ Zm = ma .masked_where (npy .fabs (Qz ) < 0.5 * npy .amax (Qz ), Z )
2225
2326
2427fig = figure ()
Original file line number Diff line number Diff line change @@ -557,7 +557,7 @@ def dedent(s):
557557 # expressions. However, this function accounted for almost 30% of
558558 # matplotlib startup time, so it is worthy of optimization at all
559559 # costs.
560-
560+
561561 if not s : # includes case of s is None
562562 return ''
563563
@@ -576,7 +576,7 @@ def dedent(s):
576576 if unindent is None :
577577 unindent = re .compile ("\n \r ? {0,%d}" % nshift )
578578 _dedent_regex [nshift ] = unindent
579-
579+
580580 result = unindent .sub ("\n " , s ).strip ()
581581 return result
582582
@@ -844,15 +844,15 @@ def report_memory(i=0): # argument may go away
844844
845845 return mem
846846
847+ _safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d'
848+ def safezip (* args ):
849+ 'make sure args are equal len before zipping'
850+ Nx = len (args [0 ])
851+ for i , arg in enumerate (args [1 :]):
852+ if len (arg ) != Nx :
853+ raise ValueError (_safezip_msg % (Nx , i + 1 , len (arg )))
854+ return zip (* args )
847855
848- def safezip (x , y ):
849- 'make sure x and y are equal len before zipping'
850- Nx = len (x )
851- Ny = len (y )
852- if Nx != Ny :
853- raise RuntimeError ('x and y must be equal length; found len(x)=%d and len(y)=%d' %
854- (Nx , Ny ))
855- return zip (x , y )
856856class MemoryMonitor :
857857 def __init__ (self , nmax = 20000 ):
858858 self ._nmax = nmax
You can’t perform that action at this time.
0 commit comments