@@ -4696,7 +4696,7 @@ def invalid_shape_exception(csize, xsize):
4696
4696
label_namer = "y" )
4697
4697
@_docstring .interpd
4698
4698
def scatter (self , x , y , s = None , c = None , marker = None , cmap = None , norm = None ,
4699
- vmin = None , vmax = None , alpha = None , linewidths = None , * ,
4699
+ vmin = None , vmax = None , colorizer = None , alpha = None , linewidths = None , * ,
4700
4700
edgecolors = None , plotnonfinite = False , ** kwargs ):
4701
4701
"""
4702
4702
A scatter plot of *y* vs. *x* with varying marker size and/or color.
@@ -4765,6 +4765,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4765
4765
4766
4766
This parameter is ignored if *c* is RGB(A).
4767
4767
4768
+ %(colorizer_doc)s
4769
+
4770
+ This parameter is ignored if *c* is RGB(A).
4771
+
4768
4772
alpha : float, default: None
4769
4773
The alpha blending value, between 0 (transparent) and 1 (opaque).
4770
4774
@@ -4938,9 +4942,13 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4938
4942
)
4939
4943
collection .set_transform (mtransforms .IdentityTransform ())
4940
4944
if colors is None :
4945
+ if colorizer :
4946
+ collection ._set_colorizer_check_keywords (colorizer , cmap , norm ,
4947
+ vmin , vmax )
4948
+ else :
4949
+ collection .set_cmap (cmap )
4950
+ collection .set_norm (norm )
4941
4951
collection .set_array (c )
4942
- collection .set_cmap (cmap )
4943
- collection .set_norm (norm )
4944
4952
collection ._scale_norm (norm , vmin , vmax )
4945
4953
else :
4946
4954
extra_kwargs = {
@@ -4975,7 +4983,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4975
4983
@_docstring .dedent_interpd
4976
4984
def hexbin (self , x , y , C = None , gridsize = 100 , bins = None ,
4977
4985
xscale = 'linear' , yscale = 'linear' , extent = None ,
4978
- cmap = None , norm = None , vmin = None , vmax = None ,
4986
+ cmap = None , norm = None , vmin = None , vmax = None , colorizer = None ,
4979
4987
alpha = None , linewidths = None , edgecolors = 'face' ,
4980
4988
reduce_C_function = np .mean , mincnt = None , marginals = False ,
4981
4989
** kwargs ):
@@ -5089,6 +5097,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
5089
5097
5090
5098
%(vmin_vmax_doc)s
5091
5099
5100
+ %(colorizer_doc)s
5101
+
5092
5102
alpha : float between 0 and 1, optional
5093
5103
The alpha blending value, between 0 (transparent) and 1 (opaque).
5094
5104
@@ -5291,9 +5301,12 @@ def reduce_C_function(C: array) -> float
5291
5301
bins = np .sort (bins )
5292
5302
accum = bins .searchsorted (accum )
5293
5303
5304
+ if colorizer :
5305
+ collection ._set_colorizer_check_keywords (colorizer , cmap , norm , vmin , vmax )
5306
+ else :
5307
+ collection .set_cmap (cmap )
5308
+ collection .set_norm (norm )
5294
5309
collection .set_array (accum )
5295
- collection .set_cmap (cmap )
5296
- collection .set_norm (norm )
5297
5310
collection .set_alpha (alpha )
5298
5311
collection ._internal_update (kwargs )
5299
5312
collection ._scale_norm (norm , vmin , vmax )
@@ -5728,7 +5741,7 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
5728
5741
@_docstring .interpd
5729
5742
def imshow (self , X , cmap = None , norm = None , * , aspect = None ,
5730
5743
interpolation = None , alpha = None ,
5731
- vmin = None , vmax = None , origin = None , extent = None ,
5744
+ vmin = None , vmax = None , colorizer = None , origin = None , extent = None ,
5732
5745
interpolation_stage = None , filternorm = True , filterrad = 4.0 ,
5733
5746
resample = None , url = None , ** kwargs ):
5734
5747
"""
@@ -5776,6 +5789,10 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5776
5789
5777
5790
This parameter is ignored if *X* is RGB(A).
5778
5791
5792
+ %(colorizer_doc)s
5793
+
5794
+ This parameter is ignored if *X* is RGB(A).
5795
+
5779
5796
aspect : {'equal', 'auto'} or float or None, default: None
5780
5797
The aspect ratio of the Axes. This parameter is particularly
5781
5798
relevant for images since it determines whether data pixels are
@@ -5938,7 +5955,7 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
5938
5955
`~matplotlib.pyplot.imshow` expects RGB images adopting the straight
5939
5956
(unassociated) alpha representation.
5940
5957
"""
5941
- im = mimage .AxesImage (self , cmap = cmap , norm = norm ,
5958
+ im = mimage .AxesImage (self , cmap = cmap , norm = norm , colorizer = colorizer ,
5942
5959
interpolation = interpolation , origin = origin ,
5943
5960
extent = extent , filternorm = filternorm ,
5944
5961
filterrad = filterrad , resample = resample ,
@@ -6082,7 +6099,7 @@ def _interp_grid(X):
6082
6099
@_preprocess_data ()
6083
6100
@_docstring .dedent_interpd
6084
6101
def pcolor (self , * args , shading = None , alpha = None , norm = None , cmap = None ,
6085
- vmin = None , vmax = None , ** kwargs ):
6102
+ vmin = None , vmax = None , colorizer = None , ** kwargs ):
6086
6103
r"""
6087
6104
Create a pseudocolor plot with a non-regular rectangular grid.
6088
6105
@@ -6160,6 +6177,8 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
6160
6177
6161
6178
%(vmin_vmax_doc)s
6162
6179
6180
+ %(colorizer_doc)s
6181
+
6163
6182
edgecolors : {'none', None, 'face', color, color sequence}, optional
6164
6183
The color of the edges. Defaults to 'none'. Possible values:
6165
6184
@@ -6267,7 +6286,8 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
6267
6286
coords = stack ([X , Y ], axis = - 1 )
6268
6287
6269
6288
collection = mcoll .PolyQuadMesh (
6270
- coords , array = C , cmap = cmap , norm = norm , alpha = alpha , ** kwargs )
6289
+ coords , array = C , cmap = cmap , norm = norm , colorizer = colorizer ,
6290
+ alpha = alpha , ** kwargs )
6271
6291
collection ._scale_norm (norm , vmin , vmax )
6272
6292
6273
6293
# Transform from native to data coordinates?
@@ -6299,7 +6319,8 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
6299
6319
@_preprocess_data ()
6300
6320
@_docstring .dedent_interpd
6301
6321
def pcolormesh (self , * args , alpha = None , norm = None , cmap = None , vmin = None ,
6302
- vmax = None , shading = None , antialiased = False , ** kwargs ):
6322
+ vmax = None , colorizer = None , shading = None , antialiased = False ,
6323
+ ** kwargs ):
6303
6324
"""
6304
6325
Create a pseudocolor plot with a non-regular rectangular grid.
6305
6326
@@ -6368,6 +6389,8 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6368
6389
6369
6390
%(vmin_vmax_doc)s
6370
6391
6392
+ %(colorizer_doc)s
6393
+
6371
6394
edgecolors : {'none', None, 'face', color, color sequence}, optional
6372
6395
The color of the edges. Defaults to 'none'. Possible values:
6373
6396
@@ -6497,7 +6520,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6497
6520
6498
6521
collection = mcoll .QuadMesh (
6499
6522
coords , antialiased = antialiased , shading = shading ,
6500
- array = C , cmap = cmap , norm = norm , alpha = alpha , ** kwargs )
6523
+ array = C , cmap = cmap , norm = norm , colorizer = colorizer , alpha = alpha , ** kwargs )
6501
6524
collection ._scale_norm (norm , vmin , vmax )
6502
6525
6503
6526
coords = coords .reshape (- 1 , 2 ) # flatten the grid structure; keep x, y
@@ -6526,7 +6549,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6526
6549
@_preprocess_data ()
6527
6550
@_docstring .dedent_interpd
6528
6551
def pcolorfast (self , * args , alpha = None , norm = None , cmap = None , vmin = None ,
6529
- vmax = None , ** kwargs ):
6552
+ vmax = None , colorizer = None , ** kwargs ):
6530
6553
"""
6531
6554
Create a pseudocolor plot with a non-regular rectangular grid.
6532
6555
@@ -6612,6 +6635,10 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6612
6635
6613
6636
This parameter is ignored if *C* is RGB(A).
6614
6637
6638
+ %(colorizer_doc)s
6639
+
6640
+ This parameter is ignored if *C* is RGB(A).
6641
+
6615
6642
alpha : float, default: None
6616
6643
The alpha blending value, between 0 (transparent) and 1 (opaque).
6617
6644
@@ -6675,7 +6702,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6675
6702
raise ValueError ("C must be 2D or 3D" )
6676
6703
collection = mcoll .QuadMesh (
6677
6704
coords , array = C ,
6678
- alpha = alpha , cmap = cmap , norm = norm ,
6705
+ alpha = alpha , cmap = cmap , norm = norm , colorizer = colorizer ,
6679
6706
antialiased = False , edgecolors = "none" )
6680
6707
self .add_collection (collection , autolim = False )
6681
6708
xl , xr , yb , yt = x .min (), x .max (), y .min (), y .max ()
@@ -6685,15 +6712,15 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6685
6712
extent = xl , xr , yb , yt = x [0 ], x [- 1 ], y [0 ], y [- 1 ]
6686
6713
if style == "image" :
6687
6714
im = mimage .AxesImage (
6688
- self , cmap = cmap , norm = norm ,
6715
+ self , cmap = cmap , norm = norm , colorizer = colorizer ,
6689
6716
data = C , alpha = alpha , extent = extent ,
6690
6717
interpolation = 'nearest' , origin = 'lower' ,
6691
6718
** kwargs )
6692
6719
elif style == "pcolorimage" :
6693
6720
im = mimage .PcolorImage (
6694
6721
self , x , y , C ,
6695
- cmap = cmap , norm = norm , alpha = alpha , extent = extent ,
6696
- ** kwargs )
6722
+ cmap = cmap , norm = norm , colorizer = colorizer , alpha = alpha ,
6723
+ extent = extent , ** kwargs )
6697
6724
self .add_image (im )
6698
6725
ret = im
6699
6726
@@ -7426,6 +7453,8 @@ def hist2d(self, x, y, bins=10, range=None, density=False, weights=None,
7426
7453
7427
7454
%(vmin_vmax_doc)s
7428
7455
7456
+ %(colorizer_doc)s
7457
+
7429
7458
alpha : ``0 <= scalar <= 1`` or ``None``, optional
7430
7459
The alpha blending value.
7431
7460