@@ -3048,6 +3048,53 @@ def pcolormesh(self,x,y,data,**kwargs):
30483048 ax .set_frame_on (False )
30493049 return ret
30503050
3051+ def hexbin (self ,x ,y ,** kwargs ):
3052+ """
3053+ Make a hexagonal binning plot of x versus y, where x, y are 1-D
3054+ sequences of the same length, N. If C is None (the default), this is a
3055+ histogram of the number of occurences of the observations at
3056+ (x[i],y[i]).
3057+
3058+ If C is specified, it specifies values at the coordinate (x[i],y[i]).
3059+ These values are accumulated for each hexagonal bin and then reduced
3060+ according to reduce_C_function, which defaults to numpy?s mean function
3061+ (np.mean). (If C is specified, it must also be a 1-D sequence of the
3062+ same length as x and y.)
3063+
3064+ x, y and/or C may be masked arrays, in which case only unmasked points
3065+ will be plotted.
3066+
3067+ (see matplotlib.pyplot.hexbin documentation).
3068+
3069+ Extra keyword ``ax`` can be used to override the default axis instance.
3070+
3071+ Other \**kwargs passed on to matplotlib.pyplot.hexbin
3072+ """
3073+ ax , plt = self ._ax_plt_from_kw (kwargs )
3074+ # allow callers to override the hold state by passing hold=True|False
3075+ b = ax .ishold ()
3076+ h = kwargs .pop ('hold' ,None )
3077+ if h is not None :
3078+ ax .hold (h )
3079+ try :
3080+ # make x,y masked arrays
3081+ # (masked where data is outside of projection limb)
3082+ x = ma .masked_values (np .where (x > 1.e20 ,1.e20 ,x ), 1.e20 )
3083+ y = ma .masked_values (np .where (y > 1.e20 ,1.e20 ,y ), 1.e20 )
3084+ ret = ax .hexbin (x ,y ,** kwargs )
3085+ except :
3086+ ax .hold (b )
3087+ raise
3088+ ax .hold (b )
3089+ # reset current active image (only if pyplot is imported).
3090+ if plt :
3091+ plt .sci (ret )
3092+ # clip for round polar plots.
3093+ if self .round : ret = self ._clipcircle (ax ,ret )
3094+ # set axes limits to fit map region.
3095+ self .set_axes_limits (ax = ax )
3096+ return ret
3097+
30513098 def contour (self ,x ,y ,data ,* args ,** kwargs ):
30523099 """
30533100 Make a contour plot over the map
0 commit comments