-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathcolormaps.html
More file actions
1070 lines (844 loc) · 119 KB
/
colormaps.html
File metadata and controls
1070 lines (844 loc) · 119 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta content="codex" name="keywords" />
<title>Choosing Colormaps in Matplotlib — Matplotlib 3.7.0 documentation</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
<!-- Loaded before other Sphinx assets -->
<link href="../../_static/styles/theme.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link href="../../_static/styles/bootstrap.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link href="../../_static/styles/pydata-sphinx-theme.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link href="../../_static/vendor/fontawesome/6.1.2/css/all.min.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../_static/vendor/fontawesome/6.1.2/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../_static/vendor/fontawesome/6.1.2/webfonts/fa-brands-400.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../_static/vendor/fontawesome/6.1.2/webfonts/fa-regular-400.woff2">
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/css/style.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/graphviz.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-binder.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-dataframe.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-rendered-html.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/design-style.4045f2051d55cab465a707391d5b2007.min.css?v3.7.0-3-g235131a6bc" />
<link rel="stylesheet" type="text/css" href="../../_static/mpl.css?v3.7.0-3-g235131a6bc" />
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=796348d33e8b1d947c94">
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=796348d33e8b1d947c94">
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/jquery.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/underscore.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/doctools.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/sphinx_highlight.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/clipboard.min.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/copybutton.js?v3.7.0-3-g235131a6bc"></script>
<script src="../../_static/design-tabs.js?v3.7.0-3-g235131a6bc"></script>
<script data-domain="matplotlib.org" defer="defer" src="https://views.scientific-python.org/js/script.js"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'tutorials/colors/colormaps';</script>
<script>
DOCUMENTATION_OPTIONS.theme_switcher_json_url = 'https://matplotlib.org/devdocs/_static/switcher.json';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = '3.7.0';
</script>
<link rel="canonical" href="https://matplotlib.org/stable/tutorials/colors/colormaps.html" />
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Matplotlib 3.7.0 documentation"
href="../../_static/opensearch.xml"/>
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Text" href="../text/index.html" />
<link rel="prev" title="Colormap Normalization" href="colormapnorms.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en">
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="180" data-default-mode="">
<a class="skip-link" href="#main-content">Skip to main content</a>
<input type="checkbox" class="sidebar-toggle" name="__primary" id="__primary">
<label class="overlay overlay-primary" for="__primary"></label>
<input type="checkbox" class="sidebar-toggle" name="__secondary" id="__secondary">
<label class="overlay overlay-secondary" for="__secondary"></label>
<div class="search-button__wrapper">
<div class="search-button__overlay"></div>
<div class="search-button__search-container">
<form class="bd-search d-flex align-items-center" action="../../search.html" method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form>
</div>
</div>
<nav class="bd-header navbar navbar-expand-lg bd-navbar" id="navbar-main"><div class="bd-header__inner bd-page-width">
<label class="sidebar-toggle primary-toggle" for="__primary">
<span class="fa-solid fa-bars"></span>
</label>
<div id="navbar-start">
<a class="navbar-brand logo" href="../../index.html">
<img src="../../_static/images/logo2.svg" class="logo__image only-light" alt="Logo image">
<img src="../../_static/images/logo_dark.svg" class="logo__image only-dark" alt="Logo image">
</a>
</div>
<div class="col-lg-9 navbar-header-items">
<div id="navbar-center" class="mr-auto">
<div class="navbar-center-item">
<ul id="navbar-main-elements" class="navbar-nav">
<li class="nav-item">
<a class="reference internal nav-link" href="../../plot_types/index.html">Plot types</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../gallery/index.html">Examples</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../index.html">Tutorials</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../api/index.html">Reference</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/index.html">User guide</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../devel/index.html">Develop</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/release_notes.html">Releases</a>
</li>
</ul>
</div>
</div>
<div id="navbar-end">
<div class="navbar-end-item navbar-persistent--container">
<button class="btn btn-sm navbar-btn search-button search-button__button" title="Search" aria-label="Search" data-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
</button>
</div>
<div class="navbar-end-item">
<button class="theme-switch-button btn btn-sm btn-outline-primary navbar-btn rounded-circle" title="light/dark" aria-label="light/dark" data-toggle="tooltip">
<span class="theme-switch" data-mode="light"><i class="fa-solid fa-sun"></i></span>
<span class="theme-switch" data-mode="dark"><i class="fa-solid fa-moon"></i></span>
<span class="theme-switch" data-mode="auto"><i class="fa-solid fa-circle-half-stroke"></i></span>
</button>
</div>
<div class="navbar-end-item">
<div class="version-switcher__container dropdown">
<button type="button" class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle" data-toggle="dropdown">
stable <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div class="version-switcher__menu dropdown-menu list-group-flush py-0">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
</div>
<div class="navbar-end-item">
<ul id="navbar-icon-links" class="navbar-nav" aria-label="Icon Links">
<li class="nav-item">
<a href="https://gitter.im/matplotlib/matplotlib" title="Gitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-gitter"></i></span>
<label class="sr-only">Gitter</label></a>
</li>
<li class="nav-item">
<a href="https://discourse.matplotlib.org" title="Discourse" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-discourse"></i></span>
<label class="sr-only">Discourse</label></a>
</li>
<li class="nav-item">
<a href="https://github.com/matplotlib/matplotlib" title="GitHub" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-github"></i></span>
<label class="sr-only">GitHub</label></a>
</li>
<li class="nav-item">
<a href="https://twitter.com/matplotlib/" title="Twitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-twitter"></i></span>
<label class="sr-only">Twitter</label></a>
</li>
</ul>
</div>
</div>
</div>
<div class="navbar-persistent--mobile">
<button class="btn btn-sm navbar-btn search-button search-button__button" title="Search" aria-label="Search" data-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
</button>
</div>
<label class="sidebar-toggle secondary-toggle" for="__secondary">
<span class="fa-solid fa-outdent"></span>
</label>
</div>
</nav>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<div class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
<div class="sidebar-header-items__center">
<div class="navbar-center-item">
<ul id="navbar-main-elements" class="navbar-nav">
<li class="nav-item">
<a class="reference internal nav-link" href="../../plot_types/index.html">Plot types</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../gallery/index.html">Examples</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../index.html">Tutorials</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../api/index.html">Reference</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/index.html">User guide</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../devel/index.html">Develop</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/release_notes.html">Releases</a>
</li>
</ul>
</div>
</div>
<div class="sidebar-header-items__end">
<div class="navbar-end-item">
<button class="theme-switch-button btn btn-sm btn-outline-primary navbar-btn rounded-circle" title="light/dark" aria-label="light/dark" data-toggle="tooltip">
<span class="theme-switch" data-mode="light"><i class="fa-solid fa-sun"></i></span>
<span class="theme-switch" data-mode="dark"><i class="fa-solid fa-moon"></i></span>
<span class="theme-switch" data-mode="auto"><i class="fa-solid fa-circle-half-stroke"></i></span>
</button>
</div>
<div class="navbar-end-item">
<div class="version-switcher__container dropdown">
<button type="button" class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle" data-toggle="dropdown">
stable <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div class="version-switcher__menu dropdown-menu list-group-flush py-0">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
</div>
<div class="navbar-end-item">
<ul id="navbar-icon-links" class="navbar-nav" aria-label="Icon Links">
<li class="nav-item">
<a href="https://gitter.im/matplotlib/matplotlib" title="Gitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-gitter"></i></span>
<label class="sr-only">Gitter</label></a>
</li>
<li class="nav-item">
<a href="https://discourse.matplotlib.org" title="Discourse" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-discourse"></i></span>
<label class="sr-only">Discourse</label></a>
</li>
<li class="nav-item">
<a href="https://github.com/matplotlib/matplotlib" title="GitHub" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-github"></i></span>
<label class="sr-only">GitHub</label></a>
</li>
<li class="nav-item">
<a href="https://twitter.com/matplotlib/" title="Twitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-twitter"></i></span>
<label class="sr-only">Twitter</label></a>
</li>
</ul>
</div>
</div>
</div>
<div class="sidebar-start-items sidebar-primary__section">
<div class="sidebar-start-items__item"><nav class="bd-links" id="bd-docs-nav" aria-label="Section navigation">
<p class="bd-links__title" role="heading" aria-level="1">
Section Navigation
</p>
<div class="bd-toc-item navbar-nav">
<ul class="current nav bd-sidenav">
<li class="toctree-l1 has-children"><a class="reference internal" href="../introductory/index.html">Introductory</a><input class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-1"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../introductory/quick_start.html">Quick start guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../introductory/pyplot.html">Pyplot tutorial</a></li>
<li class="toctree-l2"><a class="reference internal" href="../introductory/images.html">Image tutorial</a></li>
<li class="toctree-l2"><a class="reference internal" href="../introductory/lifecycle.html">The Lifecycle of a Plot</a></li>
<li class="toctree-l2"><a class="reference internal" href="../introductory/customizing.html">Customizing Matplotlib with style sheets and rcParams</a></li>
<li class="toctree-l2"><a class="reference internal" href="../introductory/animation_tutorial.html">Animations using Matplotlib</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../intermediate/index.html">Intermediate</a><input class="toctree-checkbox" id="toctree-checkbox-2" name="toctree-checkbox-2" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-2"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/artists.html">Artist tutorial</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/legend_guide.html">Legend guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/color_cycle.html">Styling with cycler</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/constrainedlayout_guide.html">Constrained Layout Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/tight_layout_guide.html">Tight Layout guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/arranging_axes.html">Arranging multiple Axes in a Figure</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/autoscale.html">Autoscaling</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intermediate/imshow_extent.html"><em>origin</em> and <em>extent</em> in <code class="xref py py-obj docutils literal notranslate"><span class="pre">imshow</span></code></a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../advanced/index.html">Advanced</a><input class="toctree-checkbox" id="toctree-checkbox-3" name="toctree-checkbox-3" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-3"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../advanced/blitting.html">Faster rendering by using blitting</a></li>
<li class="toctree-l2"><a class="reference internal" href="../advanced/path_tutorial.html">Path Tutorial</a></li>
<li class="toctree-l2"><a class="reference internal" href="../advanced/patheffects_guide.html">Path effects guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../advanced/transforms_tutorial.html">Transformations Tutorial</a></li>
</ul>
</li>
<li class="toctree-l1 current active has-children"><a class="reference internal" href="index.html">Colors</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="colors.html">Specifying colors</a></li>
<li class="toctree-l2"><a class="reference internal" href="colorbar_only.html">Customized Colorbars Tutorial</a></li>
<li class="toctree-l2"><a class="reference internal" href="colormap-manipulation.html">Creating Colormaps in Matplotlib</a></li>
<li class="toctree-l2"><a class="reference internal" href="colormapnorms.html">Colormap Normalization</a></li>
<li class="toctree-l2 current active"><a class="current reference internal" href="#">Choosing Colormaps in Matplotlib</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../text/index.html">Text</a><input class="toctree-checkbox" id="toctree-checkbox-5" name="toctree-checkbox-5" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-5"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../text/text_intro.html">Text in Matplotlib Plots</a></li>
<li class="toctree-l2"><a class="reference internal" href="../text/text_props.html">Text properties and layout</a></li>
<li class="toctree-l2"><a class="reference internal" href="../text/annotations.html">Annotations</a></li>
<li class="toctree-l2"><a class="reference internal" href="../text/mathtext.html">Writing mathematical expressions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../text/pgf.html">Text rendering with XeLaTeX/LuaLaTeX via the <code class="docutils literal notranslate"><span class="pre">pgf</span></code> backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="../text/usetex.html">Text rendering with LaTeX</a></li>
</ul>
</li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../toolkits/index.html">Toolkits</a><input class="toctree-checkbox" id="toctree-checkbox-6" name="toctree-checkbox-6" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-6"><i class="fa-solid fa-chevron-down"></i></label><ul>
<li class="toctree-l2"><a class="reference internal" href="../toolkits/axes_grid.html">The axes_grid1 toolkit</a></li>
<li class="toctree-l2"><a class="reference internal" href="../toolkits/axisartist.html">The axisartist toolkit</a></li>
<li class="toctree-l2"><a class="reference internal" href="../toolkits/mplot3d.html">The mplot3d toolkit</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../provisional/index.html">Provisional</a></li>
</ul>
</div>
</nav>
</div>
</div>
<div class="sidebar-end-items sidebar-primary__section">
<div class="sidebar-end-items__item">
</div>
</div>
<div id="rtd-footer-container"></div>
</div>
<main id="main-content" class="bd-main">
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article">
</div>
<article class="bd-article" role="main">
<div class="sphx-glr-download-link-note admonition note">
<p class="admonition-title">Note</p>
<p>Click <a class="reference internal" href="#sphx-glr-download-tutorials-colors-colormaps-py"><span class="std std-ref">here</span></a>
to download the full example code</p>
</div>
<section class="sphx-glr-example-title" id="choosing-colormaps-in-matplotlib">
<span id="sphx-glr-tutorials-colors-colormaps-py"></span><h1>Choosing Colormaps in Matplotlib<a class="headerlink" href="#choosing-colormaps-in-matplotlib" title="Permalink to this heading">#</a></h1>
<p>Matplotlib has a number of built-in colormaps accessible via
<a class="reference internal" href="../../api/matplotlib_configuration_api.html#matplotlib.colormaps" title="matplotlib.colormaps"><code class="xref py py-obj docutils literal notranslate"><span class="pre">matplotlib.colormaps</span></code></a>. There are also external libraries that
have many extra colormaps, which can be viewed in the
<a class="reference external" href="https://matplotlib.org/mpl-third-party/#colormaps-and-styles">Third-party colormaps</a> section of the Matplotlib documentation.
Here we briefly discuss how to choose between the many options. For
help on creating your own colormaps, see
<a class="reference internal" href="colormap-manipulation.html"><span class="doc">Creating Colormaps in Matplotlib</span></a>.</p>
<section id="overview">
<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this heading">#</a></h2>
<p>The idea behind choosing a good colormap is to find a good representation in 3D
colorspace for your data set. The best colormap for any given data set depends
on many things including:</p>
<ul class="simple">
<li><p>Whether representing form or metric data (<a class="reference internal" href="#ware" id="id1"><span>[Ware]</span></a>)</p></li>
<li><p>Your knowledge of the data set (<em>e.g.</em>, is there a critical value
from which the other values deviate?)</p></li>
<li><p>If there is an intuitive color scheme for the parameter you are plotting</p></li>
<li><p>If there is a standard in the field the audience may be expecting</p></li>
</ul>
<p>For many applications, a perceptually uniform colormap is the best choice;
i.e. a colormap in which equal steps in data are perceived as equal
steps in the color space. Researchers have found that the human brain
perceives changes in the lightness parameter as changes in the data
much better than, for example, changes in hue. Therefore, colormaps
which have monotonically increasing lightness through the colormap
will be better interpreted by the viewer. Wonderful examples of
perceptually uniform colormaps can be found in the
<a class="reference external" href="https://matplotlib.org/mpl-third-party/#colormaps-and-styles">Third-party colormaps</a> section as well.</p>
<p>Color can be represented in 3D space in various ways. One way to represent color
is using CIELAB. In CIELAB, color space is represented by lightness,
<span class="math notranslate nohighlight">\(L^*\)</span>; red-green, <span class="math notranslate nohighlight">\(a^*\)</span>; and yellow-blue, <span class="math notranslate nohighlight">\(b^*\)</span>. The lightness
parameter <span class="math notranslate nohighlight">\(L^*\)</span> can then be used to learn more about how the matplotlib
colormaps will be perceived by viewers.</p>
<p>An excellent starting resource for learning about human perception of colormaps
is from <a class="reference internal" href="#ibm" id="id2"><span>[IBM]</span></a>.</p>
</section>
<section id="classes-of-colormaps">
<span id="color-colormaps-reference"></span><h2>Classes of colormaps<a class="headerlink" href="#classes-of-colormaps" title="Permalink to this heading">#</a></h2>
<p>Colormaps are often split into several categories based on their function (see,
<em>e.g.</em>, <a class="reference internal" href="#moreland" id="id3"><span>[Moreland]</span></a>):</p>
<ol class="arabic simple">
<li><p>Sequential: change in lightness and often saturation of color
incrementally, often using a single hue; should be used for
representing information that has ordering.</p></li>
<li><p>Diverging: change in lightness and possibly saturation of two
different colors that meet in the middle at an unsaturated color;
should be used when the information being plotted has a critical
middle value, such as topography or when the data deviates around
zero.</p></li>
<li><p>Cyclic: change in lightness of two different colors that meet in
the middle and beginning/end at an unsaturated color; should be
used for values that wrap around at the endpoints, such as phase
angle, wind direction, or time of day.</p></li>
<li><p>Qualitative: often are miscellaneous colors; should be used to
represent information which does not have ordering or
relationships.</p></li>
</ol>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">mpl</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
<span class="kn">from</span> <span class="nn">colorspacious</span> <span class="kn">import</span> <span class="n">cspace_converter</span>
</pre></div>
</div>
<p>First, we'll show the range of each colormap. Note that some seem
to change more "quickly" than others.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmaps</span></a> <span class="o">=</span> <span class="p">{}</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy.linspace" title="numpy.linspace" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-function"><span class="n">np</span><span class="o">.</span><span class="n">linspace</span></a><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">256</span><span class="p">)</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.vstack.html#numpy.vstack" title="numpy.vstack" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-function"><span class="n">np</span><span class="o">.</span><span class="n">vstack</span></a><span class="p">((</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a><span class="p">,</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a><span class="p">))</span>
<span class="k">def</span> <span class="nf">plot_color_gradients</span><span class="p">(</span><span class="n">category</span><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">):</span>
<span class="c1"># Create figure and adjust figure height to number of colormaps</span>
<span class="n">nrows</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">)</span>
<span class="n">figh</span> <span class="o">=</span> <span class="mf">0.35</span> <span class="o">+</span> <span class="mf">0.15</span> <span class="o">+</span> <span class="p">(</span><span class="n">nrows</span> <span class="o">+</span> <span class="p">(</span><span class="n">nrows</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mf">0.1</span><span class="p">)</span> <span class="o">*</span> <span class="mf">0.22</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">fig</span></a><span class="p">,</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a> <span class="o">=</span> <a href="../../api/_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots" title="matplotlib.pyplot.subplots" class="sphx-glr-backref-module-matplotlib-pyplot sphx-glr-backref-type-py-function"><span class="n">plt</span><span class="o">.</span><span class="n">subplots</span></a><span class="p">(</span><span class="n">nrows</span><span class="o">=</span><span class="n">nrows</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mf">6.4</span><span class="p">,</span> <span class="n">figh</span><span class="p">))</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure.subplots_adjust" title="matplotlib.figure.Figure.subplots_adjust" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-method"><span class="n">fig</span><span class="o">.</span><span class="n">subplots_adjust</span></a><span class="p">(</span><span class="n">top</span><span class="o">=</span><span class="mi">1</span> <span class="o">-</span> <span class="mf">0.35</span> <span class="o">/</span> <span class="n">figh</span><span class="p">,</span> <span class="n">bottom</span><span class="o">=</span><span class="mf">0.15</span> <span class="o">/</span> <span class="n">figh</span><span class="p">,</span>
<span class="n">left</span><span class="o">=</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">right</span><span class="o">=</span><span class="mf">0.99</span><span class="p">)</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_title</span><span class="p">(</span><span class="sa">f</span><span class="s1">'</span><span class="si">{</span><span class="n">category</span><span class="si">}</span><span class="s1"> colormaps'</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">14</span><span class="p">)</span>
<span class="k">for</span> <a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a><span class="p">,</span> <span class="n">name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">):</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.imshow.html#matplotlib.axes.Axes.imshow" title="matplotlib.axes.Axes.imshow" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">imshow</span></a><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a><span class="p">,</span> <span class="n">aspect</span><span class="o">=</span><span class="s1">'auto'</span><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap</span></a><span class="o">=</span><a href="../../api/cm_api.html#matplotlib.cm.ColormapRegistry" title="matplotlib.cm.ColormapRegistry" class="sphx-glr-backref-module-matplotlib-cm sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">mpl</span><span class="o">.</span><span class="n">colormaps</span></a><span class="p">[</span><span class="n">name</span><span class="p">])</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.text.html#matplotlib.axes.Axes.text" title="matplotlib.axes.Axes.text" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">text</span></a><span class="p">(</span><span class="o">-</span><span class="mf">0.01</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">va</span><span class="o">=</span><span class="s1">'center'</span><span class="p">,</span> <span class="n">ha</span><span class="o">=</span><span class="s1">'right'</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span>
<span class="n">transform</span><span class="o">=</span><a href="../../api/transformations.html#matplotlib.transforms.BboxTransformTo" title="matplotlib.transforms.BboxTransformTo" class="sphx-glr-backref-module-matplotlib-transforms sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span><span class="o">.</span><span class="n">transAxes</span></a><span class="p">)</span>
<span class="c1"># Turn off *all* ticks & spines, not just the ones with colormaps.</span>
<span class="k">for</span> <a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a> <span class="ow">in</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a><span class="p">:</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.set_axis_off.html#matplotlib.axes.Axes.set_axis_off" title="matplotlib.axes.Axes.set_axis_off" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">set_axis_off</span></a><span class="p">()</span>
<span class="c1"># Save colormap list for later.</span>
<a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmaps</span></a><span class="p">[</span><span class="n">category</span><span class="p">]</span> <span class="o">=</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a>
</pre></div>
</div>
<section id="sequential">
<h3>Sequential<a class="headerlink" href="#sequential" title="Permalink to this heading">#</a></h3>
<p>For the Sequential plots, the lightness value increases monotonically through
the colormaps. This is good. Some of the <span class="math notranslate nohighlight">\(L^*\)</span> values in the colormaps
span from 0 to 100 (binary and the other grayscale), and others start around
<span class="math notranslate nohighlight">\(L^*=20\)</span>. Those that have a smaller range of <span class="math notranslate nohighlight">\(L^*\)</span> will accordingly
have a smaller perceptual range. Note also that the <span class="math notranslate nohighlight">\(L^*\)</span> function varies
amongst the colormaps: some are approximately linear in <span class="math notranslate nohighlight">\(L^*\)</span> and others
are more curved.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plot_color_gradients</span><span class="p">(</span><span class="s1">'Perceptually Uniform Sequential'</span><span class="p">,</span>
<span class="p">[</span><span class="s1">'viridis'</span><span class="p">,</span> <span class="s1">'plasma'</span><span class="p">,</span> <span class="s1">'inferno'</span><span class="p">,</span> <span class="s1">'magma'</span><span class="p">,</span> <span class="s1">'cividis'</span><span class="p">])</span>
</pre></div>
</div>
<img src="../../_images/sphx_glr_colormaps_001.png" srcset="../../_images/sphx_glr_colormaps_001.png, ../../_images/sphx_glr_colormaps_001_2_0x.png 2.0x" alt="Perceptually Uniform Sequential colormaps" class = "sphx-glr-single-img"/><div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plot_color_gradients</span><span class="p">(</span><span class="s1">'Sequential'</span><span class="p">,</span>
<span class="p">[</span><span class="s1">'Greys'</span><span class="p">,</span> <span class="s1">'Purples'</span><span class="p">,</span> <span class="s1">'Blues'</span><span class="p">,</span> <span class="s1">'Greens'</span><span class="p">,</span> <span class="s1">'Oranges'</span><span class="p">,</span> <span class="s1">'Reds'</span><span class="p">,</span>
<span class="s1">'YlOrBr'</span><span class="p">,</span> <span class="s1">'YlOrRd'</span><span class="p">,</span> <span class="s1">'OrRd'</span><span class="p">,</span> <span class="s1">'PuRd'</span><span class="p">,</span> <span class="s1">'RdPu'</span><span class="p">,</span> <span class="s1">'BuPu'</span><span class="p">,</span>
<span class="s1">'GnBu'</span><span class="p">,</span> <span class="s1">'PuBu'</span><span class="p">,</span> <span class="s1">'YlGnBu'</span><span class="p">,</span> <span class="s1">'PuBuGn'</span><span class="p">,</span> <span class="s1">'BuGn'</span><span class="p">,</span> <span class="s1">'YlGn'</span><span class="p">])</span>
</pre></div>
</div>
<img src="../../_images/sphx_glr_colormaps_002.png" srcset="../../_images/sphx_glr_colormaps_002.png, ../../_images/sphx_glr_colormaps_002_2_0x.png 2.0x" alt="Sequential colormaps" class = "sphx-glr-single-img"/></section>
<section id="sequential2">
<h3>Sequential2<a class="headerlink" href="#sequential2" title="Permalink to this heading">#</a></h3>
<p>Many of the <span class="math notranslate nohighlight">\(L^*\)</span> values from the Sequential2 plots are monotonically
increasing, but some (autumn, cool, spring, and winter) plateau or even go both
up and down in <span class="math notranslate nohighlight">\(L^*\)</span> space. Others (afmhot, copper, gist_heat, and hot)
have kinks in the <span class="math notranslate nohighlight">\(L^*\)</span> functions. Data that is being represented in a
region of the colormap that is at a plateau or kink will lead to a perception of
banding of the data in those values in the colormap (see <a class="reference internal" href="#mycarta-banding" id="id4"><span>[mycarta-banding]</span></a> for
an excellent example of this).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plot_color_gradients</span><span class="p">(</span><span class="s1">'Sequential (2)'</span><span class="p">,</span>
<span class="p">[</span><span class="s1">'binary'</span><span class="p">,</span> <span class="s1">'gist_yarg'</span><span class="p">,</span> <span class="s1">'gist_gray'</span><span class="p">,</span> <span class="s1">'gray'</span><span class="p">,</span> <span class="s1">'bone'</span><span class="p">,</span>
<span class="s1">'pink'</span><span class="p">,</span> <span class="s1">'spring'</span><span class="p">,</span> <span class="s1">'summer'</span><span class="p">,</span> <span class="s1">'autumn'</span><span class="p">,</span> <span class="s1">'winter'</span><span class="p">,</span> <span class="s1">'cool'</span><span class="p">,</span>
<span class="s1">'Wistia'</span><span class="p">,</span> <span class="s1">'hot'</span><span class="p">,</span> <span class="s1">'afmhot'</span><span class="p">,</span> <span class="s1">'gist_heat'</span><span class="p">,</span> <span class="s1">'copper'</span><span class="p">])</span>
</pre></div>
</div>
<img src="../../_images/sphx_glr_colormaps_003.png" srcset="../../_images/sphx_glr_colormaps_003.png, ../../_images/sphx_glr_colormaps_003_2_0x.png 2.0x" alt="Sequential (2) colormaps" class = "sphx-glr-single-img"/></section>
<section id="diverging">
<h3>Diverging<a class="headerlink" href="#diverging" title="Permalink to this heading">#</a></h3>
<p>For the Diverging maps, we want to have monotonically increasing <span class="math notranslate nohighlight">\(L^*\)</span>
values up to a maximum, which should be close to <span class="math notranslate nohighlight">\(L^*=100\)</span>, followed by
monotonically decreasing <span class="math notranslate nohighlight">\(L^*\)</span> values. We are looking for approximately
equal minimum <span class="math notranslate nohighlight">\(L^*\)</span> values at opposite ends of the colormap. By these
measures, BrBG and RdBu are good options. coolwarm is a good option, but it
doesn't span a wide range of <span class="math notranslate nohighlight">\(L^*\)</span> values (see grayscale section below).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plot_color_gradients</span><span class="p">(</span><span class="s1">'Diverging'</span><span class="p">,</span>
<span class="p">[</span><span class="s1">'PiYG'</span><span class="p">,</span> <span class="s1">'PRGn'</span><span class="p">,</span> <span class="s1">'BrBG'</span><span class="p">,</span> <span class="s1">'PuOr'</span><span class="p">,</span> <span class="s1">'RdGy'</span><span class="p">,</span> <span class="s1">'RdBu'</span><span class="p">,</span> <span class="s1">'RdYlBu'</span><span class="p">,</span>
<span class="s1">'RdYlGn'</span><span class="p">,</span> <span class="s1">'Spectral'</span><span class="p">,</span> <span class="s1">'coolwarm'</span><span class="p">,</span> <span class="s1">'bwr'</span><span class="p">,</span> <span class="s1">'seismic'</span><span class="p">])</span>
</pre></div>
</div>
<img src="../../_images/sphx_glr_colormaps_004.png" srcset="../../_images/sphx_glr_colormaps_004.png, ../../_images/sphx_glr_colormaps_004_2_0x.png 2.0x" alt="Diverging colormaps" class = "sphx-glr-single-img"/></section>
<section id="cyclic">
<h3>Cyclic<a class="headerlink" href="#cyclic" title="Permalink to this heading">#</a></h3>
<p>For Cyclic maps, we want to start and end on the same color, and meet a
symmetric center point in the middle. <span class="math notranslate nohighlight">\(L^*\)</span> should change monotonically
from start to middle, and inversely from middle to end. It should be symmetric
on the increasing and decreasing side, and only differ in hue. At the ends and
middle, <span class="math notranslate nohighlight">\(L^*\)</span> will reverse direction, which should be smoothed in
<span class="math notranslate nohighlight">\(L^*\)</span> space to reduce artifacts. See <a class="reference internal" href="#kovesi-colormaps" id="id5"><span>[kovesi-colormaps]</span></a> for more
information on the design of cyclic maps.</p>
<p>The often-used HSV colormap is included in this set of colormaps, although it
is not symmetric to a center point. Additionally, the <span class="math notranslate nohighlight">\(L^*\)</span> values vary
widely throughout the colormap, making it a poor choice for representing data
for viewers to see perceptually. See an extension on this idea at
<a class="reference internal" href="#mycarta-jet" id="id6"><span>[mycarta-jet]</span></a>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plot_color_gradients</span><span class="p">(</span><span class="s1">'Cyclic'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'twilight'</span><span class="p">,</span> <span class="s1">'twilight_shifted'</span><span class="p">,</span> <span class="s1">'hsv'</span><span class="p">])</span>
</pre></div>
</div>
<img src="../../_images/sphx_glr_colormaps_005.png" srcset="../../_images/sphx_glr_colormaps_005.png, ../../_images/sphx_glr_colormaps_005_2_0x.png 2.0x" alt="Cyclic colormaps" class = "sphx-glr-single-img"/></section>
<section id="qualitative">
<h3>Qualitative<a class="headerlink" href="#qualitative" title="Permalink to this heading">#</a></h3>
<p>Qualitative colormaps are not aimed at being perceptual maps, but looking at the
lightness parameter can verify that for us. The <span class="math notranslate nohighlight">\(L^*\)</span> values move all over
the place throughout the colormap, and are clearly not monotonically increasing.
These would not be good options for use as perceptual colormaps.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plot_color_gradients</span><span class="p">(</span><span class="s1">'Qualitative'</span><span class="p">,</span>
<span class="p">[</span><span class="s1">'Pastel1'</span><span class="p">,</span> <span class="s1">'Pastel2'</span><span class="p">,</span> <span class="s1">'Paired'</span><span class="p">,</span> <span class="s1">'Accent'</span><span class="p">,</span> <span class="s1">'Dark2'</span><span class="p">,</span>
<span class="s1">'Set1'</span><span class="p">,</span> <span class="s1">'Set2'</span><span class="p">,</span> <span class="s1">'Set3'</span><span class="p">,</span> <span class="s1">'tab10'</span><span class="p">,</span> <span class="s1">'tab20'</span><span class="p">,</span> <span class="s1">'tab20b'</span><span class="p">,</span>
<span class="s1">'tab20c'</span><span class="p">])</span>
</pre></div>
</div>
<img src="../../_images/sphx_glr_colormaps_006.png" srcset="../../_images/sphx_glr_colormaps_006.png, ../../_images/sphx_glr_colormaps_006_2_0x.png 2.0x" alt="Qualitative colormaps" class = "sphx-glr-single-img"/></section>
<section id="miscellaneous">
<h3>Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this heading">#</a></h3>
<p>Some of the miscellaneous colormaps have particular uses for which
they have been created. For example, gist_earth, ocean, and terrain
all seem to be created for plotting topography (green/brown) and water
depths (blue) together. We would expect to see a divergence in these
colormaps, then, but multiple kinks may not be ideal, such as in
gist_earth and terrain. CMRmap was created to convert well to
grayscale, though it does appear to have some small kinks in
<span class="math notranslate nohighlight">\(L^*\)</span>. cubehelix was created to vary smoothly in both lightness
and hue, but appears to have a small hump in the green hue area. turbo
was created to display depth and disparity data.</p>
<p>The often-used jet colormap is included in this set of colormaps. We can see
that the <span class="math notranslate nohighlight">\(L^*\)</span> values vary widely throughout the colormap, making it a
poor choice for representing data for viewers to see perceptually. See an
extension on this idea at <a class="reference internal" href="#mycarta-jet" id="id7"><span>[mycarta-jet]</span></a> and <a class="reference internal" href="#turbo" id="id8"><span>[turbo]</span></a>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">plot_color_gradients</span><span class="p">(</span><span class="s1">'Miscellaneous'</span><span class="p">,</span>
<span class="p">[</span><span class="s1">'flag'</span><span class="p">,</span> <span class="s1">'prism'</span><span class="p">,</span> <span class="s1">'ocean'</span><span class="p">,</span> <span class="s1">'gist_earth'</span><span class="p">,</span> <span class="s1">'terrain'</span><span class="p">,</span>
<span class="s1">'gist_stern'</span><span class="p">,</span> <span class="s1">'gnuplot'</span><span class="p">,</span> <span class="s1">'gnuplot2'</span><span class="p">,</span> <span class="s1">'CMRmap'</span><span class="p">,</span>
<span class="s1">'cubehelix'</span><span class="p">,</span> <span class="s1">'brg'</span><span class="p">,</span> <span class="s1">'gist_rainbow'</span><span class="p">,</span> <span class="s1">'rainbow'</span><span class="p">,</span> <span class="s1">'jet'</span><span class="p">,</span>
<span class="s1">'turbo'</span><span class="p">,</span> <span class="s1">'nipy_spectral'</span><span class="p">,</span> <span class="s1">'gist_ncar'</span><span class="p">])</span>
<a href="../../api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show" title="matplotlib.pyplot.show" class="sphx-glr-backref-module-matplotlib-pyplot sphx-glr-backref-type-py-function"><span class="n">plt</span><span class="o">.</span><span class="n">show</span></a><span class="p">()</span>
</pre></div>
</div>
<img src="../../_images/sphx_glr_colormaps_007.png" srcset="../../_images/sphx_glr_colormaps_007.png, ../../_images/sphx_glr_colormaps_007_2_0x.png 2.0x" alt="Miscellaneous colormaps" class = "sphx-glr-single-img"/></section>
</section>
<section id="lightness-of-matplotlib-colormaps">
<h2>Lightness of Matplotlib colormaps<a class="headerlink" href="#lightness-of-matplotlib-colormaps" title="Permalink to this heading">#</a></h2>
<p>Here we examine the lightness values of the matplotlib colormaps.
Note that some documentation on the colormaps is available
(<a class="reference internal" href="#list-colormaps" id="id9"><span>[list-colormaps]</span></a>).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><a href="https://docs.python.org/3/library/stdtypes.html#dict.update" title="builtins.dict.update" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-method"><span class="n">mpl</span><span class="o">.</span><span class="n">rcParams</span><span class="o">.</span><span class="n">update</span></a><span class="p">({</span><span class="s1">'font.size'</span><span class="p">:</span> <span class="mi">12</span><span class="p">})</span>
<span class="c1"># Number of colormap per subplot for particular cmap categories</span>
<a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">_DSUBS</span></a> <span class="o">=</span> <span class="p">{</span><span class="s1">'Perceptually Uniform Sequential'</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">'Sequential'</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span>
<span class="s1">'Sequential (2)'</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s1">'Diverging'</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s1">'Cyclic'</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="s1">'Qualitative'</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span> <span class="s1">'Miscellaneous'</span><span class="p">:</span> <span class="mi">6</span><span class="p">}</span>
<span class="c1"># Spacing between the colormaps of a subplot</span>
<a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">_DC</span></a> <span class="o">=</span> <span class="p">{</span><span class="s1">'Perceptually Uniform Sequential'</span><span class="p">:</span> <span class="mf">1.4</span><span class="p">,</span> <span class="s1">'Sequential'</span><span class="p">:</span> <span class="mf">0.7</span><span class="p">,</span>
<span class="s1">'Sequential (2)'</span><span class="p">:</span> <span class="mf">1.4</span><span class="p">,</span> <span class="s1">'Diverging'</span><span class="p">:</span> <span class="mf">1.4</span><span class="p">,</span> <span class="s1">'Cyclic'</span><span class="p">:</span> <span class="mf">1.4</span><span class="p">,</span>
<span class="s1">'Qualitative'</span><span class="p">:</span> <span class="mf">1.4</span><span class="p">,</span> <span class="s1">'Miscellaneous'</span><span class="p">:</span> <span class="mf">1.4</span><span class="p">}</span>
<span class="c1"># Indices to step through colormap</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy.linspace" title="numpy.linspace" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-function"><span class="n">np</span><span class="o">.</span><span class="n">linspace</span></a><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
<span class="c1"># Do plot</span>
<span class="k">for</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a> <span class="ow">in</span> <a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmaps</span></a><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="c1"># Do subplots so that colormaps have enough space.</span>
<span class="c1"># Default is 6 colormaps per subplot.</span>
<a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dsub</span></a> <span class="o">=</span> <a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">_DSUBS</span></a><span class="o">.</span><span class="n">get</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a><span class="p">,</span> <span class="mi">6</span><span class="p">)</span>
<a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">nsubplots</span></a> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ufunc.html#numpy.ufunc" title="numpy.ufunc" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">np</span><span class="o">.</span><span class="n">ceil</span></a><span class="p">(</span><span class="nb">len</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">)</span> <span class="o">/</span> <a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dsub</span></a><span class="p">))</span>
<span class="c1"># squeeze=False to handle similarly the case of a single subplot</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">fig</span></a><span class="p">,</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a> <span class="o">=</span> <a href="../../api/_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots" title="matplotlib.pyplot.subplots" class="sphx-glr-backref-module-matplotlib-pyplot sphx-glr-backref-type-py-function"><span class="n">plt</span><span class="o">.</span><span class="n">subplots</span></a><span class="p">(</span><span class="n">nrows</span><span class="o">=</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">nsubplots</span></a><span class="p">,</span> <span class="n">squeeze</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">7</span><span class="p">,</span> <span class="mf">2.6</span><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">nsubplots</span></a><span class="p">))</span>
<span class="k">for</span> <a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">i</span></a><span class="p">,</span> <a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.flatiter.html#numpy.flatiter" title="numpy.flatiter" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span><span class="o">.</span><span class="n">flat</span></a><span class="p">):</span>
<a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">locs</span></a> <span class="o">=</span> <span class="p">[]</span> <span class="c1"># locations for text labels</span>
<span class="k">for</span> <a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">j</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap</span></a> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">[</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">i</span></a><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dsub</span></a><span class="p">:(</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">i</span></a><span class="o">+</span><span class="mi">1</span><span class="p">)</span><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dsub</span></a><span class="p">]):</span>
<span class="c1"># Get RGB values for colormap and convert the colormap in</span>
<span class="c1"># CAM02-UCS colorspace. lab[0, :, 0] is the lightness.</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">rgb</span></a> <span class="o">=</span> <a href="../../api/cm_api.html#matplotlib.cm.ColormapRegistry" title="matplotlib.cm.ColormapRegistry" class="sphx-glr-backref-module-matplotlib-cm sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">mpl</span><span class="o">.</span><span class="n">colormaps</span></a><span class="p">[</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap</span></a><span class="p">](</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a><span class="p">)[</span><a href="https://numpy.org/doc/stable/reference/constants.html#numpy.newaxis" title="numpy.newaxis" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-data"><span class="n">np</span><span class="o">.</span><span class="n">newaxis</span></a><span class="p">,</span> <span class="p">:,</span> <span class="p">:</span><span class="mi">3</span><span class="p">]</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">lab</span></a> <span class="o">=</span> <span class="n">cspace_converter</span><span class="p">(</span><span class="s2">"sRGB1"</span><span class="p">,</span> <span class="s2">"CAM02-UCS"</span><span class="p">)(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">rgb</span></a><span class="p">)</span>
<span class="c1"># Plot colormap L values. Do separately for each category</span>
<span class="c1"># so each plot can be pretty. To make scatter markers change</span>
<span class="c1"># color along plot:</span>
<span class="c1"># https://stackoverflow.com/q/8202605/</span>
<span class="k">if</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a> <span class="o">==</span> <span class="s1">'Sequential'</span><span class="p">:</span>
<span class="c1"># These colormaps all start at high lightness, but we want them</span>
<span class="c1"># reversed to look nice in the plot, so reverse the order.</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">y_</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">lab</span></a><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="p">::</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">c_</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">y_</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">lab</span></a><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="p">:,</span> <span class="mi">0</span><span class="p">]</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">c_</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a>
<a href="https://docs.python.org/3/library/functions.html#float" title="builtins.float" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dc</span></a> <span class="o">=</span> <a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">_DC</span></a><span class="o">.</span><span class="n">get</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a><span class="p">,</span> <span class="mf">1.4</span><span class="p">)</span> <span class="c1"># cmaps horizontal spacing</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.scatter.html#matplotlib.axes.Axes.scatter" title="matplotlib.axes.Axes.scatter" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">scatter</span></a><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a> <span class="o">+</span> <a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">j</span></a><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#float" title="builtins.float" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dc</span></a><span class="p">,</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">y_</span></a><span class="p">,</span> <span class="n">c</span><span class="o">=</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">c_</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap</span></a><span class="o">=</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap</span></a><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="mi">300</span><span class="p">,</span> <span class="n">linewidths</span><span class="o">=</span><span class="mf">0.0</span><span class="p">)</span>
<span class="c1"># Store locations for colormap labels</span>
<span class="k">if</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a> <span class="ow">in</span> <span class="p">(</span><span class="s1">'Perceptually Uniform Sequential'</span><span class="p">,</span>
<span class="s1">'Sequential'</span><span class="p">):</span>
<a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">locs</span></a><span class="o">.</span><span class="n">append</span><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">j</span></a><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#float" title="builtins.float" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dc</span></a><span class="p">)</span>
<span class="k">elif</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a> <span class="ow">in</span> <span class="p">(</span><span class="s1">'Diverging'</span><span class="p">,</span> <span class="s1">'Qualitative'</span><span class="p">,</span> <span class="s1">'Cyclic'</span><span class="p">,</span>
<span class="s1">'Miscellaneous'</span><span class="p">,</span> <span class="s1">'Sequential (2)'</span><span class="p">):</span>
<a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">locs</span></a><span class="o">.</span><span class="n">append</span><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a><span class="p">[</span><span class="nb">int</span><span class="p">(</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span><span class="o">.</span><span class="n">size</span></a><span class="o">/</span><span class="mf">2.</span><span class="p">)]</span> <span class="o">+</span> <a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">j</span></a><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#float" title="builtins.float" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dc</span></a><span class="p">)</span>
<span class="c1"># Set up the axis limits:</span>
<span class="c1"># * the 1st subplot is used as a reference for the x-axis limits</span>
<span class="c1"># * lightness values goes from 0 to 100 (y-axis limits)</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.set_xlim.html#matplotlib.axes.Axes.set_xlim" title="matplotlib.axes.Axes.set_xlim" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">set_xlim</span></a><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">get_xlim</span><span class="p">())</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.set_ylim.html#matplotlib.axes.Axes.set_ylim" title="matplotlib.axes.Axes.set_ylim" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">set_ylim</span></a><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">100.0</span><span class="p">)</span>
<span class="c1"># Set up labels for colormaps</span>
<a href="../../api/_as_gen/matplotlib.axis.XAxis.set_ticks_position.html#matplotlib.axis.XAxis.set_ticks_position" title="matplotlib.axis.XAxis.set_ticks_position" class="sphx-glr-backref-module-matplotlib-axis sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_ticks_position</span></a><span class="p">(</span><span class="s1">'top'</span><span class="p">)</span>
<a href="../../api/ticker_api.html#matplotlib.ticker.FixedLocator" title="matplotlib.ticker.FixedLocator" class="sphx-glr-backref-module-matplotlib-ticker sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ticker</span></a> <span class="o">=</span> <a href="../../api/ticker_api.html#matplotlib.ticker.FixedLocator" title="matplotlib.ticker.FixedLocator" class="sphx-glr-backref-module-matplotlib-ticker sphx-glr-backref-type-py-class"><span class="n">mpl</span><span class="o">.</span><span class="n">ticker</span><span class="o">.</span><span class="n">FixedLocator</span></a><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">locs</span></a><span class="p">)</span>
<a href="../../api/_as_gen/matplotlib.axis.Axis.set_major_locator.html#matplotlib.axis.Axis.set_major_locator" title="matplotlib.axis.Axis.set_major_locator" class="sphx-glr-backref-module-matplotlib-axis sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_major_locator</span></a><span class="p">(</span><a href="../../api/ticker_api.html#matplotlib.ticker.FixedLocator" title="matplotlib.ticker.FixedLocator" class="sphx-glr-backref-module-matplotlib-ticker sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ticker</span></a><span class="p">)</span>
<a href="../../api/ticker_api.html#matplotlib.ticker.FixedFormatter" title="matplotlib.ticker.FixedFormatter" class="sphx-glr-backref-module-matplotlib-ticker sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">formatter</span></a> <span class="o">=</span> <a href="../../api/ticker_api.html#matplotlib.ticker.FixedFormatter" title="matplotlib.ticker.FixedFormatter" class="sphx-glr-backref-module-matplotlib-ticker sphx-glr-backref-type-py-class"><span class="n">mpl</span><span class="o">.</span><span class="n">ticker</span><span class="o">.</span><span class="n">FixedFormatter</span></a><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">[</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">i</span></a><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dsub</span></a><span class="p">:(</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">i</span></a><span class="o">+</span><span class="mi">1</span><span class="p">)</span><span class="o">*</span><a href="https://docs.python.org/3/library/functions.html#int" title="builtins.int" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">dsub</span></a><span class="p">])</span>
<a href="../../api/_as_gen/matplotlib.axis.Axis.set_major_formatter.html#matplotlib.axis.Axis.set_major_formatter" title="matplotlib.axis.Axis.set_major_formatter" class="sphx-glr-backref-module-matplotlib-axis sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_major_formatter</span></a><span class="p">(</span><a href="../../api/ticker_api.html#matplotlib.ticker.FixedFormatter" title="matplotlib.ticker.FixedFormatter" class="sphx-glr-backref-module-matplotlib-ticker sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">formatter</span></a><span class="p">)</span>
<a href="../../api/_as_gen/matplotlib.axis.Axis.set_tick_params.html#matplotlib.axis.Axis.set_tick_params" title="matplotlib.axis.Axis.set_tick_params" class="sphx-glr-backref-module-matplotlib-axis sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_tick_params</span></a><span class="p">(</span><span class="n">rotation</span><span class="o">=</span><span class="mi">50</span><span class="p">)</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.set_ylabel.html#matplotlib.axes.Axes.set_ylabel" title="matplotlib.axes.Axes.set_ylabel" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">set_ylabel</span></a><span class="p">(</span><span class="s1">'Lightness $L^*$'</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">12</span><span class="p">)</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.set_xlabel.html#matplotlib.axes.Axes.set_xlabel" title="matplotlib.axes.Axes.set_xlabel" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">set_xlabel</span></a><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a> <span class="o">+</span> <span class="s1">' colormaps'</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">14</span><span class="p">)</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure.tight_layout" title="matplotlib.figure.Figure.tight_layout" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-method"><span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span></a><span class="p">(</span><span class="n">h_pad</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">pad</span><span class="o">=</span><span class="mf">1.5</span><span class="p">)</span>
<a href="../../api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show" title="matplotlib.pyplot.show" class="sphx-glr-backref-module-matplotlib-pyplot sphx-glr-backref-type-py-function"><span class="n">plt</span><span class="o">.</span><span class="n">show</span></a><span class="p">()</span>
</pre></div>
</div>
<ul class="sphx-glr-horizontal">
<li><img src="../../_images/sphx_glr_colormaps_008.png" srcset="../../_images/sphx_glr_colormaps_008.png, ../../_images/sphx_glr_colormaps_008_2_0x.png 2.0x" alt="colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_009.png" srcset="../../_images/sphx_glr_colormaps_009.png, ../../_images/sphx_glr_colormaps_009_2_0x.png 2.0x" alt="colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_010.png" srcset="../../_images/sphx_glr_colormaps_010.png, ../../_images/sphx_glr_colormaps_010_2_0x.png 2.0x" alt="colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_011.png" srcset="../../_images/sphx_glr_colormaps_011.png, ../../_images/sphx_glr_colormaps_011_2_0x.png 2.0x" alt="colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_012.png" srcset="../../_images/sphx_glr_colormaps_012.png, ../../_images/sphx_glr_colormaps_012_2_0x.png 2.0x" alt="colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_013.png" srcset="../../_images/sphx_glr_colormaps_013.png, ../../_images/sphx_glr_colormaps_013_2_0x.png 2.0x" alt="colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_014.png" srcset="../../_images/sphx_glr_colormaps_014.png, ../../_images/sphx_glr_colormaps_014_2_0x.png 2.0x" alt="colormaps" class = "sphx-glr-multi-img"/></li>
</ul>
</section>
<section id="grayscale-conversion">
<h2>Grayscale conversion<a class="headerlink" href="#grayscale-conversion" title="Permalink to this heading">#</a></h2>
<p>It is important to pay attention to conversion to grayscale for color
plots, since they may be printed on black and white printers. If not
carefully considered, your readers may end up with indecipherable
plots because the grayscale changes unpredictably through the
colormap.</p>
<p>Conversion to grayscale is done in many different ways <a class="reference internal" href="#bw" id="id10"><span>[bw]</span></a>. Some of the
better ones use a linear combination of the rgb values of a pixel, but
weighted according to how we perceive color intensity. A nonlinear method of
conversion to grayscale is to use the <span class="math notranslate nohighlight">\(L^*\)</span> values of the pixels. In
general, similar principles apply for this question as they do for presenting
one's information perceptually; that is, if a colormap is chosen that is
monotonically increasing in <span class="math notranslate nohighlight">\(L^*\)</span> values, it will print in a reasonable
manner to grayscale.</p>
<p>With this in mind, we see that the Sequential colormaps have reasonable
representations in grayscale. Some of the Sequential2 colormaps have decent
enough grayscale representations, though some (autumn, spring, summer,
winter) have very little grayscale change. If a colormap like this was used
in a plot and then the plot was printed to grayscale, a lot of the
information may map to the same gray values. The Diverging colormaps mostly
vary from darker gray on the outer edges to white in the middle. Some
(PuOr and seismic) have noticeably darker gray on one side than the other
and therefore are not very symmetric. coolwarm has little range of gray scale
and would print to a more uniform plot, losing a lot of detail. Note that
overlaid, labeled contours could help differentiate between one side of the
colormap vs. the other since color cannot be used once a plot is printed to
grayscale. Many of the Qualitative and Miscellaneous colormaps, such as
Accent, hsv, jet and turbo, change from darker to lighter and back to darker
grey throughout the colormap. This would make it impossible for a viewer to
interpret the information in a plot once it is printed in grayscale.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><a href="https://docs.python.org/3/library/stdtypes.html#dict.update" title="builtins.dict.update" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-method"><span class="n">mpl</span><span class="o">.</span><span class="n">rcParams</span><span class="o">.</span><span class="n">update</span></a><span class="p">({</span><span class="s1">'font.size'</span><span class="p">:</span> <span class="mi">14</span><span class="p">})</span>
<span class="c1"># Indices to step through colormap.</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy.linspace" title="numpy.linspace" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-function"><span class="n">np</span><span class="o">.</span><span class="n">linspace</span></a><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy.linspace" title="numpy.linspace" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-function"><span class="n">np</span><span class="o">.</span><span class="n">linspace</span></a><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">256</span><span class="p">)</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.vstack.html#numpy.vstack" title="numpy.vstack" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-function"><span class="n">np</span><span class="o">.</span><span class="n">vstack</span></a><span class="p">((</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a><span class="p">,</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a><span class="p">))</span>
<span class="k">def</span> <span class="nf">plot_color_gradients</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">):</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">fig</span></a><span class="p">,</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a> <span class="o">=</span> <a href="../../api/_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots" title="matplotlib.pyplot.subplots" class="sphx-glr-backref-module-matplotlib-pyplot sphx-glr-backref-type-py-function"><span class="n">plt</span><span class="o">.</span><span class="n">subplots</span></a><span class="p">(</span><span class="n">nrows</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">),</span> <span class="n">ncols</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure.subplots_adjust" title="matplotlib.figure.Figure.subplots_adjust" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-method"><span class="n">fig</span><span class="o">.</span><span class="n">subplots_adjust</span></a><span class="p">(</span><span class="n">top</span><span class="o">=</span><span class="mf">0.95</span><span class="p">,</span> <span class="n">bottom</span><span class="o">=</span><span class="mf">0.01</span><span class="p">,</span> <span class="n">left</span><span class="o">=</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">right</span><span class="o">=</span><span class="mf">0.99</span><span class="p">,</span>
<span class="n">wspace</span><span class="o">=</span><span class="mf">0.05</span><span class="p">)</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure.suptitle" title="matplotlib.figure.Figure.suptitle" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-method"><span class="n">fig</span><span class="o">.</span><span class="n">suptitle</span></a><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a> <span class="o">+</span> <span class="s1">' colormaps'</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">14</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a><span class="o">=</span><span class="mf">0.6</span><span class="p">)</span>
<span class="k">for</span> <a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a><span class="p">,</span> <span class="n">name</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">):</span>
<span class="c1"># Get RGB values for colormap.</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">rgb</span></a> <span class="o">=</span> <a href="../../api/cm_api.html#matplotlib.cm.ColormapRegistry" title="matplotlib.cm.ColormapRegistry" class="sphx-glr-backref-module-matplotlib-cm sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">mpl</span><span class="o">.</span><span class="n">colormaps</span></a><span class="p">[</span><span class="n">name</span><span class="p">](</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">x</span></a><span class="p">)[</span><a href="https://numpy.org/doc/stable/reference/constants.html#numpy.newaxis" title="numpy.newaxis" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-data"><span class="n">np</span><span class="o">.</span><span class="n">newaxis</span></a><span class="p">,</span> <span class="p">:,</span> <span class="p">:</span><span class="mi">3</span><span class="p">]</span>
<span class="c1"># Get colormap in CAM02-UCS colorspace. We want the lightness.</span>
<a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">lab</span></a> <span class="o">=</span> <span class="n">cspace_converter</span><span class="p">(</span><span class="s2">"sRGB1"</span><span class="p">,</span> <span class="s2">"CAM02-UCS"</span><span class="p">)(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">rgb</span></a><span class="p">)</span>
<span class="n">L</span> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">lab</span></a><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="p">:,</span> <span class="mi">0</span><span class="p">]</span>
<span class="n">L</span> <span class="o">=</span> <a href="https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.float32" title="numpy.float32" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-attribute"><span class="n">np</span><span class="o">.</span><span class="n">float32</span></a><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.vstack.html#numpy.vstack" title="numpy.vstack" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-function"><span class="n">np</span><span class="o">.</span><span class="n">vstack</span></a><span class="p">((</span><span class="n">L</span><span class="p">,</span> <span class="n">L</span><span class="p">,</span> <span class="n">L</span><span class="p">)))</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">imshow</span><span class="p">(</span><a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray" title="numpy.ndarray" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">gradient</span></a><span class="p">,</span> <span class="n">aspect</span><span class="o">=</span><span class="s1">'auto'</span><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap</span></a><span class="o">=</span><a href="../../api/cm_api.html#matplotlib.cm.ColormapRegistry" title="matplotlib.cm.ColormapRegistry" class="sphx-glr-backref-module-matplotlib-cm sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">mpl</span><span class="o">.</span><span class="n">colormaps</span></a><span class="p">[</span><span class="n">name</span><span class="p">])</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">imshow</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">aspect</span><span class="o">=</span><span class="s1">'auto'</span><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap</span></a><span class="o">=</span><span class="s1">'binary_r'</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="mf">0.</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="mf">100.</span><span class="p">)</span>
<span class="n">pos</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">get_position</span><span class="p">()</span><span class="o">.</span><span class="n">bounds</span><span class="p">)</span>
<span class="n">x_text</span> <span class="o">=</span> <span class="n">pos</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mf">0.01</span>
<span class="n">y_text</span> <span class="o">=</span> <span class="n">pos</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">pos</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">/</span><span class="mf">2.</span>
<a href="../../api/figure_api.html#matplotlib.figure.Figure.text" title="matplotlib.figure.Figure.text" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-method"><span class="n">fig</span><span class="o">.</span><span class="n">text</span></a><span class="p">(</span><span class="n">x_text</span><span class="p">,</span> <span class="n">y_text</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">va</span><span class="o">=</span><span class="s1">'center'</span><span class="p">,</span> <span class="n">ha</span><span class="o">=</span><span class="s1">'right'</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="c1"># Turn off *all* ticks & spines, not just the ones with colormaps.</span>
<span class="k">for</span> <a href="../../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">ax</span></a> <span class="ow">in</span> <a href="https://numpy.org/doc/stable/reference/generated/numpy.flatiter.html#numpy.flatiter" title="numpy.flatiter" class="sphx-glr-backref-module-numpy sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">axs</span><span class="o">.</span><span class="n">flat</span></a><span class="p">:</span>
<a href="../../api/_as_gen/matplotlib.axes.Axes.set_axis_off.html#matplotlib.axes.Axes.set_axis_off" title="matplotlib.axes.Axes.set_axis_off" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-method"><span class="n">ax</span><span class="o">.</span><span class="n">set_axis_off</span></a><span class="p">()</span>
<a href="../../api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show" title="matplotlib.pyplot.show" class="sphx-glr-backref-module-matplotlib-pyplot sphx-glr-backref-type-py-function"><span class="n">plt</span><span class="o">.</span><span class="n">show</span></a><span class="p">()</span>
<span class="k">for</span> <a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a> <span class="ow">in</span> <a href="https://docs.python.org/3/library/stdtypes.html#dict" title="builtins.dict" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmaps</span></a><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">plot_color_gradients</span><span class="p">(</span><a href="https://docs.python.org/3/library/stdtypes.html#str" title="builtins.str" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_category</span></a><span class="p">,</span> <a href="https://docs.python.org/3/library/stdtypes.html#list" title="builtins.list" class="sphx-glr-backref-module-builtins sphx-glr-backref-type-py-class sphx-glr-backref-instance"><span class="n">cmap_list</span></a><span class="p">)</span>
</pre></div>
</div>
<ul class="sphx-glr-horizontal">
<li><img src="../../_images/sphx_glr_colormaps_015.png" srcset="../../_images/sphx_glr_colormaps_015.png, ../../_images/sphx_glr_colormaps_015_2_0x.png 2.0x" alt="Perceptually Uniform Sequential colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_016.png" srcset="../../_images/sphx_glr_colormaps_016.png, ../../_images/sphx_glr_colormaps_016_2_0x.png 2.0x" alt="Sequential colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_017.png" srcset="../../_images/sphx_glr_colormaps_017.png, ../../_images/sphx_glr_colormaps_017_2_0x.png 2.0x" alt="Sequential (2) colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_018.png" srcset="../../_images/sphx_glr_colormaps_018.png, ../../_images/sphx_glr_colormaps_018_2_0x.png 2.0x" alt="Diverging colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_019.png" srcset="../../_images/sphx_glr_colormaps_019.png, ../../_images/sphx_glr_colormaps_019_2_0x.png 2.0x" alt="Cyclic colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_020.png" srcset="../../_images/sphx_glr_colormaps_020.png, ../../_images/sphx_glr_colormaps_020_2_0x.png 2.0x" alt="Qualitative colormaps" class = "sphx-glr-multi-img"/></li>
<li><img src="../../_images/sphx_glr_colormaps_021.png" srcset="../../_images/sphx_glr_colormaps_021.png, ../../_images/sphx_glr_colormaps_021_2_0x.png 2.0x" alt="Miscellaneous colormaps" class = "sphx-glr-multi-img"/></li>
</ul>
</section>
<section id="color-vision-deficiencies">
<h2>Color vision deficiencies<a class="headerlink" href="#color-vision-deficiencies" title="Permalink to this heading">#</a></h2>
<p>There is a lot of information available about color blindness (<em>e.g.</em>,
<a class="reference internal" href="#colorblindness" id="id11"><span>[colorblindness]</span></a>). Additionally, there are tools available to convert images
to how they look for different types of color vision deficiencies.</p>
<p>The most common form of color vision deficiency involves differentiating
between red and green. Thus, avoiding colormaps with both red and green will
avoid many problems in general.</p>
</section>
<section id="references">
<h2>References<a class="headerlink" href="#references" title="Permalink to this heading">#</a></h2>
<div role="list" class="citation-list">
<div class="citation" id="ware" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">Ware</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="http://ccom.unh.edu/sites/default/files/publications/Ware_1988_CGA_Color_sequences_univariate_maps.pdf">http://ccom.unh.edu/sites/default/files/publications/Ware_1988_CGA_Color_sequences_univariate_maps.pdf</a></p>
</div>
<div class="citation" id="moreland" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id3">Moreland</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="http://www.kennethmoreland.com/color-maps/ColorMapsExpanded.pdf">http://www.kennethmoreland.com/color-maps/ColorMapsExpanded.pdf</a></p>
</div>
<div class="citation" id="list-colormaps" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id9">list-colormaps</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://gist.github.com/endolith/2719900#id7">https://gist.github.com/endolith/2719900#id7</a></p>
</div>
<div class="citation" id="mycarta-banding" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id4">mycarta-banding</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://mycarta.wordpress.com/2012/10/14/the-rainbow-is-deadlong-live-the-rainbow-part-4-cie-lab-heated-body/">https://mycarta.wordpress.com/2012/10/14/the-rainbow-is-deadlong-live-the-rainbow-part-4-cie-lab-heated-body/</a></p>
</div>
<div class="citation" id="mycarta-jet" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span>mycarta-jet<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id6">1</a>,<a role="doc-backlink" href="#id7">2</a>)</span>
<p><a class="reference external" href="https://mycarta.wordpress.com/2012/10/06/the-rainbow-is-deadlong-live-the-rainbow-part-3/">https://mycarta.wordpress.com/2012/10/06/the-rainbow-is-deadlong-live-the-rainbow-part-3/</a></p>
</div>
<div class="citation" id="kovesi-colormaps" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id5">kovesi-colormaps</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://arxiv.org/abs/1509.03700">https://arxiv.org/abs/1509.03700</a></p>
</div>
<div class="citation" id="bw" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id10">bw</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://tannerhelland.com/3643/grayscale-image-algorithm-vb6/">https://tannerhelland.com/3643/grayscale-image-algorithm-vb6/</a></p>
</div>
<div class="citation" id="colorblindness" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id11">colorblindness</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="http://www.color-blindness.com/">http://www.color-blindness.com/</a></p>
</div>
<div class="citation" id="ibm" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id2">IBM</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://doi.org/10.1109/VISUAL.1995.480803">https://doi.org/10.1109/VISUAL.1995.480803</a></p>
</div>
<div class="citation" id="turbo" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id8">turbo</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html">https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html</a></p>
</div>
</div>
<p class="sphx-glr-timing"><strong>Total running time of the script:</strong> ( 0 minutes 13.251 seconds)</p>
<div class="sphx-glr-footer sphx-glr-footer-example docutils container" id="sphx-glr-download-tutorials-colors-colormaps-py">
<div class="sphx-glr-download sphx-glr-download-python docutils container">
<p><a class="reference download internal" download="" href="../../_downloads/d4718022be2010da0684c60371f4593a/colormaps.py"><code class="xref download docutils literal notranslate"><span class="pre">Download</span> <span class="pre">Python</span> <span class="pre">source</span> <span class="pre">code:</span> <span class="pre">colormaps.py</span></code></a></p>
</div>
<div class="sphx-glr-download sphx-glr-download-jupyter docutils container">
<p><a class="reference download internal" download="" href="../../_downloads/be2939a518dab831c4d343d142e6c9f1/colormaps.ipynb"><code class="xref download docutils literal notranslate"><span class="pre">Download</span> <span class="pre">Jupyter</span> <span class="pre">notebook:</span> <span class="pre">colormaps.ipynb</span></code></a></p>
</div>
</div>
<p class="sphx-glr-signature"><a class="reference external" href="https://sphinx-gallery.github.io">Gallery generated by Sphinx-Gallery</a></p>
</section>
</section>
</article>
</div>
<div class="bd-sidebar-secondary bd-toc">
<div class="toc-item">
<div class="tocsection onthispage">
<i class="fa-solid fa-list"></i> On this page
</div>
<nav id="bd-toc-nav" class="page-toc">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#overview">
Overview
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#classes-of-colormaps">
Classes of colormaps
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#sequential">
Sequential
</a>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#sequential2">
Sequential2
</a>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#diverging">
Diverging
</a>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#cyclic">
Cyclic
</a>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#qualitative">
Qualitative
</a>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#miscellaneous">
Miscellaneous
</a>
</li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#lightness-of-matplotlib-colormaps">
Lightness of Matplotlib colormaps
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#grayscale-conversion">
Grayscale conversion