Matplotlib provides a number of colormaps, and others can be added using :func:`~matplotlib.cm.register_cmap`. This function documents the built-in colormaps, and will also return a list of all registered colormaps if called. You can set the colormap for an image, pcolor, scatter,
()
| 1799 | |
| 1800 | |
| 1801 | def colormaps(): |
| 1802 | """ |
| 1803 | Matplotlib provides a number of colormaps, and others can be added using |
| 1804 | :func:`~matplotlib.cm.register_cmap`. This function documents the built-in |
| 1805 | colormaps, and will also return a list of all registered colormaps if called. |
| 1806 | |
| 1807 | You can set the colormap for an image, pcolor, scatter, etc, |
| 1808 | using a keyword argument:: |
| 1809 | |
| 1810 | imshow(X, cmap=cm.hot) |
| 1811 | |
| 1812 | or using the :func:`set_cmap` function:: |
| 1813 | |
| 1814 | imshow(X) |
| 1815 | pyplot.set_cmap('hot') |
| 1816 | pyplot.set_cmap('jet') |
| 1817 | |
| 1818 | In interactive mode, :func:`set_cmap` will update the colormap post-hoc, |
| 1819 | allowing you to see which one works best for your data. |
| 1820 | |
| 1821 | All built-in colormaps can be reversed by appending ``_r``: For instance, |
| 1822 | ``gray_r`` is the reverse of ``gray``. |
| 1823 | |
| 1824 | There are several common color schemes used in visualization: |
| 1825 | |
| 1826 | Sequential schemes |
| 1827 | for unipolar data that progresses from low to high |
| 1828 | Diverging schemes |
| 1829 | for bipolar data that emphasizes positive or negative deviations from a |
| 1830 | central value |
| 1831 | Cyclic schemes |
| 1832 | for plotting values that wrap around at the endpoints, such as phase |
| 1833 | angle, wind direction, or time of day |
| 1834 | Qualitative schemes |
| 1835 | for nominal data that has no inherent ordering, where color is used |
| 1836 | only to distinguish categories |
| 1837 | |
| 1838 | Matplotlib ships with 4 perceptually uniform color maps which are |
| 1839 | the recommended color maps for sequential data: |
| 1840 | |
| 1841 | ========= =================================================== |
| 1842 | Colormap Description |
| 1843 | ========= =================================================== |
| 1844 | inferno perceptually uniform shades of black-red-yellow |
| 1845 | magma perceptually uniform shades of black-red-white |
| 1846 | plasma perceptually uniform shades of blue-red-yellow |
| 1847 | viridis perceptually uniform shades of blue-green-yellow |
| 1848 | ========= =================================================== |
| 1849 | |
| 1850 | The following colormaps are based on the `ColorBrewer |
| 1851 | <http://colorbrewer2.org>`_ color specifications and designs developed by |
| 1852 | Cynthia Brewer: |
| 1853 | |
| 1854 | ColorBrewer Diverging (luminance is highest at the midpoint, and |
| 1855 | decreases towards differently-colored endpoints): |
| 1856 | |
| 1857 | ======== =================================== |
| 1858 | Colormap Description |