Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb01462c

Browse files
trygvradQuLogic
andauthored
MultivarColormap and BivarColormap (#28454)
MultivarColormap and BivarColormapCreation and tests for the classes MultivarColormap and BivarColormap.Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
1 parent3eda5a3 commitb01462c

13 files changed

+3047
-5
lines changed

‎lib/matplotlib/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@
129129
"interactive",
130130
"is_interactive",
131131
"colormaps",
132+
"multivar_colormaps",
133+
"bivar_colormaps",
132134
"color_sequences",
133135
]
134136

@@ -1543,4 +1545,6 @@ def validate_backend(s):
15431545
# workaround: we must defer colormaps import to after loading rcParams, because
15441546
# colormap creation depends on rcParams
15451547
frommatplotlib.cmimport_colormapsascolormaps# noqa: E402
1548+
frommatplotlib.cmimport_multivar_colormapsasmultivar_colormaps# noqa: E402
1549+
frommatplotlib.cmimport_bivar_colormapsasbivar_colormaps# noqa: E402
15461550
frommatplotlib.colorsimport_color_sequencesascolor_sequences# noqa: E402

‎lib/matplotlib/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,6 @@ def _preprocess_data(
116116
)->Callable: ...
117117

118118
frommatplotlib.cmimport_colormapsascolormaps# noqa: E402
119+
frommatplotlib.cmimport_multivar_colormapsasmultivar_colormaps# noqa: E402
120+
frommatplotlib.cmimport_bivar_colormapsasbivar_colormaps# noqa: E402
119121
frommatplotlib.colorsimport_color_sequencesascolor_sequences# noqa: E402

‎lib/matplotlib/_cm_bivar.py

Lines changed: 1312 additions & 0 deletions
Large diffs are not rendered by default.

‎lib/matplotlib/_cm_multivar.py

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# auto-generated by https://github.com/trygvrad/multivariate_colormaps
2+
# date: 2024-05-28
3+
4+
from .colorsimportLinearSegmentedColormap,MultivarColormap
5+
importmatplotlibasmpl
6+
_LUTSIZE=mpl.rcParams['image.lut']
7+
8+
_2VarAddA0_data= [[0.000,0.000,0.000],
9+
[0.020,0.026,0.031],
10+
[0.049,0.068,0.085],
11+
[0.075,0.107,0.135],
12+
[0.097,0.144,0.183],
13+
[0.116,0.178,0.231],
14+
[0.133,0.212,0.279],
15+
[0.148,0.244,0.326],
16+
[0.161,0.276,0.374],
17+
[0.173,0.308,0.422],
18+
[0.182,0.339,0.471],
19+
[0.190,0.370,0.521],
20+
[0.197,0.400,0.572],
21+
[0.201,0.431,0.623],
22+
[0.204,0.461,0.675],
23+
[0.204,0.491,0.728],
24+
[0.202,0.520,0.783],
25+
[0.197,0.549,0.838],
26+
[0.187,0.577,0.895]]
27+
28+
_2VarAddA1_data= [[0.000,0.000,0.000],
29+
[0.030,0.023,0.018],
30+
[0.079,0.060,0.043],
31+
[0.125,0.093,0.065],
32+
[0.170,0.123,0.083],
33+
[0.213,0.151,0.098],
34+
[0.255,0.177,0.110],
35+
[0.298,0.202,0.120],
36+
[0.341,0.226,0.128],
37+
[0.384,0.249,0.134],
38+
[0.427,0.271,0.138],
39+
[0.472,0.292,0.141],
40+
[0.517,0.313,0.142],
41+
[0.563,0.333,0.141],
42+
[0.610,0.353,0.139],
43+
[0.658,0.372,0.134],
44+
[0.708,0.390,0.127],
45+
[0.759,0.407,0.118],
46+
[0.813,0.423,0.105]]
47+
48+
_2VarSubA0_data= [[1.000,1.000,1.000],
49+
[0.959,0.973,0.986],
50+
[0.916,0.948,0.974],
51+
[0.874,0.923,0.965],
52+
[0.832,0.899,0.956],
53+
[0.790,0.875,0.948],
54+
[0.748,0.852,0.940],
55+
[0.707,0.829,0.934],
56+
[0.665,0.806,0.927],
57+
[0.624,0.784,0.921],
58+
[0.583,0.762,0.916],
59+
[0.541,0.740,0.910],
60+
[0.500,0.718,0.905],
61+
[0.457,0.697,0.901],
62+
[0.414,0.675,0.896],
63+
[0.369,0.652,0.892],
64+
[0.320,0.629,0.888],
65+
[0.266,0.604,0.884],
66+
[0.199,0.574,0.881]]
67+
68+
_2VarSubA1_data= [[1.000,1.000,1.000],
69+
[0.982,0.967,0.955],
70+
[0.966,0.935,0.908],
71+
[0.951,0.902,0.860],
72+
[0.937,0.870,0.813],
73+
[0.923,0.838,0.765],
74+
[0.910,0.807,0.718],
75+
[0.898,0.776,0.671],
76+
[0.886,0.745,0.624],
77+
[0.874,0.714,0.577],
78+
[0.862,0.683,0.530],
79+
[0.851,0.653,0.483],
80+
[0.841,0.622,0.435],
81+
[0.831,0.592,0.388],
82+
[0.822,0.561,0.340],
83+
[0.813,0.530,0.290],
84+
[0.806,0.498,0.239],
85+
[0.802,0.464,0.184],
86+
[0.801,0.426,0.119]]
87+
88+
_3VarAddA0_data= [[0.000,0.000,0.000],
89+
[0.018,0.023,0.028],
90+
[0.040,0.056,0.071],
91+
[0.059,0.087,0.110],
92+
[0.074,0.114,0.147],
93+
[0.086,0.139,0.183],
94+
[0.095,0.163,0.219],
95+
[0.101,0.187,0.255],
96+
[0.105,0.209,0.290],
97+
[0.107,0.230,0.326],
98+
[0.105,0.251,0.362],
99+
[0.101,0.271,0.398],
100+
[0.091,0.291,0.434],
101+
[0.075,0.309,0.471],
102+
[0.046,0.325,0.507],
103+
[0.021,0.341,0.546],
104+
[0.021,0.363,0.584],
105+
[0.022,0.385,0.622],
106+
[0.023,0.408,0.661]]
107+
108+
_3VarAddA1_data= [[0.000,0.000,0.000],
109+
[0.020,0.024,0.016],
110+
[0.047,0.058,0.034],
111+
[0.072,0.088,0.048],
112+
[0.093,0.116,0.059],
113+
[0.113,0.142,0.067],
114+
[0.131,0.167,0.071],
115+
[0.149,0.190,0.074],
116+
[0.166,0.213,0.074],
117+
[0.182,0.235,0.072],
118+
[0.198,0.256,0.068],
119+
[0.215,0.276,0.061],
120+
[0.232,0.296,0.051],
121+
[0.249,0.314,0.037],
122+
[0.270,0.330,0.018],
123+
[0.288,0.347,0.000],
124+
[0.302,0.369,0.000],
125+
[0.315,0.391,0.000],
126+
[0.328,0.414,0.000]]
127+
128+
_3VarAddA2_data= [[0.000,0.000,0.000],
129+
[0.029,0.020,0.023],
130+
[0.072,0.045,0.055],
131+
[0.111,0.067,0.084],
132+
[0.148,0.085,0.109],
133+
[0.184,0.101,0.133],
134+
[0.219,0.115,0.155],
135+
[0.254,0.127,0.176],
136+
[0.289,0.138,0.195],
137+
[0.323,0.147,0.214],
138+
[0.358,0.155,0.232],
139+
[0.393,0.161,0.250],
140+
[0.429,0.166,0.267],
141+
[0.467,0.169,0.283],
142+
[0.507,0.168,0.298],
143+
[0.546,0.168,0.313],
144+
[0.580,0.172,0.328],
145+
[0.615,0.175,0.341],
146+
[0.649,0.178,0.355]]
147+
148+
cmaps= {
149+
name:LinearSegmentedColormap.from_list(name,data,_LUTSIZE)forname,datain [
150+
('2VarAddA0',_2VarAddA0_data),
151+
('2VarAddA1',_2VarAddA1_data),
152+
('2VarSubA0',_2VarSubA0_data),
153+
('2VarSubA1',_2VarSubA1_data),
154+
('3VarAddA0',_3VarAddA0_data),
155+
('3VarAddA1',_3VarAddA1_data),
156+
('3VarAddA2',_3VarAddA2_data),
157+
]}
158+
159+
cmap_families= {
160+
'2VarAddA':MultivarColormap([cmaps[f'2VarAddA{i}']foriinrange(2)],
161+
'sRGB_add',name='2VarAddA'),
162+
'2VarSubA':MultivarColormap([cmaps[f'2VarSubA{i}']foriinrange(2)],
163+
'sRGB_sub',name='2VarSubA'),
164+
'3VarAddA':MultivarColormap([cmaps[f'3VarAddA{i}']foriinrange(3)],
165+
'sRGB_add',name='3VarAddA'),
166+
}

‎lib/matplotlib/cm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
frommatplotlibimport_api,colors,cbook,scale
2525
frommatplotlib._cmimportdatad
2626
frommatplotlib._cm_listedimportcmapsascmaps_listed
27+
frommatplotlib._cm_multivarimportcmap_familiesasmultivar_cmaps
28+
frommatplotlib._cm_bivarimportcmapsasbivar_cmaps
2729

2830

2931
_LUTSIZE=mpl.rcParams['image.lut']
@@ -238,6 +240,10 @@ def get_cmap(self, cmap):
238240
_colormaps=ColormapRegistry(_gen_cmap_registry())
239241
globals().update(_colormaps)
240242

243+
_multivar_colormaps=ColormapRegistry(multivar_cmaps)
244+
245+
_bivar_colormaps=ColormapRegistry(bivar_cmaps)
246+
241247

242248
# This is an exact copy of pyplot.get_cmap(). It was removed in 3.9, but apparently
243249
# caused more user trouble than expected. Re-added for 3.9.1 and extended the

‎lib/matplotlib/cm.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class ColormapRegistry(Mapping[str, colors.Colormap]):
1818
defget_cmap(self,cmap:str|colors.Colormap)->colors.Colormap: ...
1919

2020
_colormaps:ColormapRegistry= ...
21+
_multivar_colormaps:ColormapRegistry= ...
22+
_bivar_colormaps:ColormapRegistry= ...
2123

2224
defget_cmap(name:str|colors.Colormap|None= ...,lut:int|None= ...)->colors.Colormap: ...
2325

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp