@@ -745,7 +745,7 @@ def __init__(self, name, N=256, *, bad=None, under=None, over=None):
745
745
self ._i_over = self .N + 1
746
746
self ._i_bad = self .N + 2
747
747
self ._isinit = False
748
- self .n_variates = 1
748
+ self .n_components = 1
749
749
#: When this colormap exists on a scalar mappable and colorbar_extend
750
750
#: is not False, colorbar creation will pick up ``colorbar_extend`` as
751
751
#: the default value for the ``extend`` keyword in the
@@ -1414,10 +1414,10 @@ def __init__(self, colormaps, combination_mode, name='multivariate colormap'):
1414
1414
combination_mode: str, 'sRGB_add' or 'sRGB_sub'
1415
1415
Describe how colormaps are combined in sRGB space
1416
1416
1417
- - If 'sRGB_add' -> Mixing produces brighter colors
1418
- `sRGB = sum(colors)`
1419
- - If 'sRGB_sub' -> Mixing produces darker colors
1420
- `sRGB = 1 - sum(1 - colors)`
1417
+ - If 'sRGB_add': Mixing produces brighter colors
1418
+ `` sRGB = sum(colors)` `
1419
+ - If 'sRGB_sub': Mixing produces darker colors
1420
+ `` sRGB = 1 - sum(1 - colors)` `
1421
1421
name : str, optional
1422
1422
The name of the colormap family.
1423
1423
"""
@@ -1438,22 +1438,24 @@ def __init__(self, colormaps, combination_mode, name='multivariate colormap'):
1438
1438
self ._colormaps = colormaps
1439
1439
_api .check_in_list (['sRGB_add' , 'sRGB_sub' ], combination_mode = combination_mode )
1440
1440
self ._combination_mode = combination_mode
1441
- self .n_variates = len (colormaps )
1441
+ self .n_components = len (colormaps )
1442
1442
self ._rgba_bad = (0.0 , 0.0 , 0.0 , 0.0 ) # If bad, don't paint anything.
1443
1443
1444
1444
def __call__ (self , X , alpha = None , bytes = False , clip = True ):
1445
1445
r"""
1446
1446
Parameters
1447
1447
----------
1448
1448
X : tuple (X0, X1, ...) of length equal to the number of colormaps
1449
- X0, X1 ...:
1450
- float or int, `~numpy.ndarray` or scalar
1449
+ or structured array with multiple fields, X0, X1, ...:
1450
+ Xi: float or int, `~numpy.ndarray` or scalar.
1451
1451
The data value(s) to convert to RGBA.
1452
- For floats, *Xi...* should be in the interval ``[0.0, 1.0]`` to
1453
- return the RGBA values ``X*100`` percent along the Colormap line.
1454
- For integers, *Xi...* should be in the interval ``[0, self[i].N)`` to
1455
- return RGBA values *indexed* from colormap [i] with index ``Xi``, where
1456
- self[i] is colormap i.
1452
+
1453
+ - For floats, *Xi...* should be in the interval ``[0.0, 1.0]`` to
1454
+ return the RGBA values ``X*100`` percent along the line of colormap i.
1455
+ - For integers, *Xi...* should be in the interval ``[0, self[i].N)`` to
1456
+ return RGBA values *indexed* from colormap i with
1457
+ index ``Xi``, where self[i] is colormap i.
1458
+
1457
1459
alpha : float or array-like or None
1458
1460
Alpha must be a scalar between 0 and 1, a sequence of such
1459
1461
floats with shape matching *Xi*, or None.
@@ -1470,10 +1472,14 @@ def __call__(self, X, alpha=None, bytes=False, clip=True):
1470
1472
RGBA values with a shape of ``X.shape + (4, )``.
1471
1473
"""
1472
1474
1475
+ if isinstance (X , np .ndarray ) and X .dtype .fields is not None :
1476
+ X = tuple (X [descriptor [0 ]] for descriptor in X .dtype .descr )
1477
+
1473
1478
if len (X ) != len (self ):
1474
1479
raise ValueError (
1475
1480
f'For the selected colormap the data must have a first dimension '
1476
- f'{ len (self )} , not { len (X )} ' )
1481
+ f'{ len (self )} , not { len (X )} , or be structured array ' ,
1482
+ f'with { len (self )} fields.' )
1477
1483
rgba , mask_bad = self [0 ]._get_rgba_and_mask (X [0 ], bytes = False )
1478
1484
for c , xx in zip (self [1 :], X [1 :]):
1479
1485
sub_rgba , sub_mask_bad = c ._get_rgba_and_mask (xx , bytes = False )
@@ -1561,7 +1567,7 @@ def resampled(self, lutshape):
1561
1567
Parameters
1562
1568
----------
1563
1569
lutshape : tuple of (`int`, `None`)
1564
- The tuple must have a length matching the number of variates .
1570
+ The tuple must have a length matching the number of components .
1565
1571
For each element in the tuple, if `int`, the corresponding colorbar
1566
1572
is resampled, if `None`, the corresponding colorbar is not resampled.
1567
1573
@@ -1589,15 +1595,15 @@ def with_extremes(self, *, bad=None, under=None, over=None):
1589
1595
1590
1596
Parameters
1591
1597
----------
1592
- bad: :mpltype:`color`, default: None
1598
+ bad : :mpltype:`color`, default: None
1593
1599
If Matplotlib color, the bad value is set accordingly in the copy
1594
1600
1595
- under tuple of :mpltype:`color`, default: None
1596
- If tuple, the `under` value of each component is set with the values
1601
+ under : tuple of :mpltype:`color`, default: None
1602
+ If tuple, the `` under` ` value of each component is set with the values
1597
1603
from the tuple.
1598
1604
1599
- over tuple of :mpltype:`color`, default: None
1600
- If tuple, the `over` value of each component is set with the values
1605
+ over : tuple of :mpltype:`color`, default: None
1606
+ If tuple, the `` over` ` value of each component is set with the values
1601
1607
from the tuple.
1602
1608
1603
1609
Returns
@@ -1697,7 +1703,7 @@ def __init__(self, N=256, M=256, shape='square', origin=(0, 0),
1697
1703
self ._rgba_bad = (0.0 , 0.0 , 0.0 , 0.0 ) # If bad, don't paint anything.
1698
1704
self ._rgba_outside = (1.0 , 0.0 , 1.0 , 1.0 )
1699
1705
self ._isinit = False
1700
- self .n_variates = 2
1706
+ self .n_components = 2
1701
1707
self ._origin = (float (origin [0 ]), float (origin [1 ]))
1702
1708
'''#: When this colormap exists on a scalar mappable and colorbar_extend
1703
1709
#: is not False, colorbar creation will pick up ``colorbar_extend`` as
@@ -1709,7 +1715,8 @@ def __call__(self, X, alpha=None, bytes=False):
1709
1715
r"""
1710
1716
Parameters
1711
1717
----------
1712
- X : tuple (X0, X1), X0 and X1: float or int or array-like
1718
+ X : tuple (X0, X1) or structured array with two fields, X0 and X1:
1719
+ Xi: float or int or array-like.
1713
1720
The data value(s) to convert to RGBA.
1714
1721
1715
1722
- For floats, *X* should be in the interval ``[0.0, 1.0]`` to
@@ -1731,10 +1738,14 @@ def __call__(self, X, alpha=None, bytes=False):
1731
1738
RGBA values with a shape of ``X.shape + (4, )``.
1732
1739
"""
1733
1740
1741
+ # unwrap structured data.
1742
+ if isinstance (X , np .ndarray ) and X .dtype .fields is not None :
1743
+ X = tuple (X [descriptor [0 ]] for descriptor in X .dtype .descr )
1744
+
1734
1745
if len (X ) != 2 :
1735
1746
raise ValueError (
1736
- f 'For a `BivarColormap` the data must have a first dimension '
1737
- f'2, not { len (X )} ' )
1747
+ 'For a `BivarColormap` the data must have a first dimension '
1748
+ f'2, not { len (X )} , or be a structured array with 2 fields. ' )
1738
1749
1739
1750
if not self ._isinit :
1740
1751
self ._init ()
@@ -2264,8 +2275,8 @@ class Norm(ABC):
2264
2275
2265
2276
Subclasses include `Normalize` which maps from a scalar to
2266
2277
a scalar. However, this class makes no such requirement, and subclasses may
2267
- support the normalization of multiple variates simultaneously, with
2268
- separate normalization for each variate .
2278
+ support the normalization of multiple components simultaneously, with
2279
+ separate normalization for each component .
2269
2280
"""
2270
2281
2271
2282
def __init__ (self ):
0 commit comments