@@ -7945,6 +7945,70 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
79457945 else :
79467946 return n , bins , cbook .silent_list ('Lists of Patches' , patches )
79477947
7948+
7949+ @docstring .dedent_interpd
7950+ def hist2d (self , x , y , bins = 10 , range = None , normed = False , weights = None ,
7951+ cmin = None , cmax = None , ** kwargs ):
7952+ """
7953+ Call signature::
7954+
7955+ hist2d(x, y, bins = None, range=None, weights=None, cmin=None, cmax=None **kwargs)
7956+ Make a 2d histogram plot of *x* versus *y*, where *x*,
7957+ *y* are 1-D sequences of the same length
7958+
7959+ The return value is (counts,xedges,yedges,Image)
7960+
7961+ Optional keyword arguments:
7962+ *bins*: [None | int | [int, int] | array_like | [array, array]]
7963+ The bin specification:
7964+ If int, the number of bins for the two dimensions (nx=ny=bins).
7965+ If [int, int], the number of bins in each dimension (nx, ny = bins).
7966+ If array_like, the bin edges for the two dimensions (x_edges=y_edges=bins).
7967+ If [array, array], the bin edges in each dimension (x_edges, y_edges = bins).
7968+ The default value is 10.
7969+
7970+ *range*: [*None* | array_like shape(2,2)]
7971+ The leftmost and rightmost edges of the bins along each dimension (if not specified
7972+ explicitly in the bins parameters): [[xmin, xmax], [ymin, ymax]]. All values outside of
7973+ this range will be considered outliers and not tallied in the histogram.
7974+
7975+ *normed*:[True|False]
7976+ Normalize histogram.
7977+ The default value is False
7978+
7979+ *weights*: [*None* | array]
7980+ An array of values w_i weighing each sample (x_i, y_i).
7981+
7982+ *cmin* : [None| scalar]
7983+ All bins that has count less than cmin will not be displayed
7984+ and these count values in the return value count histogram will also be set to nan upon return
7985+
7986+ *cmax* : [None| scalar]
7987+ All bins that has count more than cmax will not be displayed (set to none before passing to imshow)
7988+ and these count values in the return value count histogram will also be set to nan upon return
7989+
7990+ Remaining keyword arguments are passed directly to :meth:pcolorfast
7991+
7992+ **Example:**
7993+
7994+ .. plot:: mpl_examples/pylab_examples/hist2d_demo.py
7995+ """
7996+
7997+ # xrange becomes range after 2to3
7998+ bin_range = range
7999+ range = __builtins__ ["range" ]
8000+ h ,xedges ,yedges = np .histogram2d (x , y , bins = bins , range = bin_range ,
8001+ normed = normed , weights = weights )
8002+
8003+ if cmin is not None : h [h < cmin ]= None
8004+ if cmax is not None : h [h > cmax ]= None
8005+
8006+ pc = self .pcolorfast (xedges ,yedges ,h .T ,** kwargs )
8007+ self .set_xlim (xedges [0 ],xedges [- 1 ])
8008+ self .set_ylim (yedges [0 ],yedges [- 1 ])
8009+
8010+ return h ,xedges ,yedges ,pc
8011+
79488012 @docstring .dedent_interpd
79498013 def psd (self , x , NFFT = 256 , Fs = 2 , Fc = 0 , detrend = mlab .detrend_none ,
79508014 window = mlab .window_hanning , noverlap = 0 , pad_to = None ,
0 commit comments