Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4772c9d

Browse files
committed
Add coolwarm color map. Revised patch. Originally submitted by Sameer Grover to matplotlib-devel on 18 Jul 2011.
1 parent c5b38d6 commit 4772c9d

File tree

1 file changed

+110
-1
lines changed

1 file changed

+110
-1
lines changed

lib/matplotlib/_cm.py

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,115 @@ def gfunc32(x):
16281628
'blue': lambda x: 1 - x,
16291629
}
16301630

1631+
# This cool to warm color map was generated from Table 2 of
1632+
# "Diverging Color Maps for Scientific Visualization (Expanded)"
1633+
# by Kenneth Moreland. <http://www.cs.unm.edu/~kmorel/documents/ColorMaps/>
1634+
_coolwarm_data = {
1635+
'red': [
1636+
(0.0, 0.23137255, 0.23137255),
1637+
(0.03125, 0.26666668, 0.26666668),
1638+
(0.0625, 0.3019608, 0.3019608),
1639+
(0.09375, 0.34117648, 0.34117648),
1640+
(0.125, 0.38431373, 0.38431373),
1641+
(0.15625, 0.42352942, 0.42352942),
1642+
(0.1875, 0.46666667, 0.46666667),
1643+
(0.21875, 0.50980395, 0.50980395),
1644+
(0.25, 0.5529412, 0.5529412),
1645+
(0.28125, 0.59607846, 0.59607846),
1646+
(0.3125, 0.63921571, 0.63921571),
1647+
(0.34375, 0.68235296, 0.68235296),
1648+
(0.375, 0.72156864, 0.72156864),
1649+
(0.40625, 0.76078433, 0.76078433),
1650+
(0.4375, 0.80000001, 0.80000001),
1651+
(0.46875, 0.83529413, 0.83529413),
1652+
(0.5, 0.86666667, 0.86666667),
1653+
(0.53125, 0.89803922, 0.89803922),
1654+
(0.5625, 0.9254902, 0.9254902),
1655+
(0.59375, 0.94509804, 0.94509804),
1656+
(0.625, 0.96078432, 0.96078432),
1657+
(0.65625, 0.96862745, 0.96862745),
1658+
(0.6875, 0.96862745, 0.96862745),
1659+
(0.71875, 0.96862745, 0.96862745),
1660+
(0.75, 0.95686275, 0.95686275),
1661+
(0.78125, 0.94509804, 0.94509804),
1662+
(0.8125, 0.9254902, 0.9254902),
1663+
(0.84375, 0.89803922, 0.89803922),
1664+
(0.875, 0.87058824, 0.87058824),
1665+
(0.90625, 0.83529413, 0.83529413),
1666+
(0.9375, 0.79607844, 0.79607844),
1667+
(0.96875, 0.75294119, 0.75294119),
1668+
(1.0, 0.70588237, 0.70588237)],
1669+
'green': [
1670+
(0.0, 0.29803923, 0.29803923),
1671+
(0.03125, 0.35294119, 0.35294119),
1672+
(0.0625, 0.40784314, 0.40784314),
1673+
(0.09375, 0.45882353, 0.45882353),
1674+
(0.125, 0.50980395, 0.50980395),
1675+
(0.15625, 0.55686277, 0.55686277),
1676+
(0.1875, 0.60392159, 0.60392159),
1677+
(0.21875, 0.64705884, 0.64705884),
1678+
(0.25, 0.6901961, 0.6901961),
1679+
(0.28125, 0.72549021, 0.72549021),
1680+
(0.3125, 0.76078433, 0.76078433),
1681+
(0.34375, 0.78823531, 0.78823531),
1682+
(0.375, 0.81568629, 0.81568629),
1683+
(0.40625, 0.83529413, 0.83529413),
1684+
(0.4375, 0.8509804, 0.8509804),
1685+
(0.46875, 0.85882354, 0.85882354),
1686+
(0.5, 0.86666667, 0.86666667),
1687+
(0.53125, 0.84705883, 0.84705883),
1688+
(0.5625, 0.82745099, 0.82745099),
1689+
(0.59375, 0.80000001, 0.80000001),
1690+
(0.625, 0.76862746, 0.76862746),
1691+
(0.65625, 0.73333335, 0.73333335),
1692+
(0.6875, 0.69411767, 0.69411767),
1693+
(0.71875, 0.65098041, 0.65098041),
1694+
(0.75, 0.60392159, 0.60392159),
1695+
(0.78125, 0.5529412, 0.5529412),
1696+
(0.8125, 0.49803922, 0.49803922),
1697+
(0.84375, 0.43921569, 0.43921569),
1698+
(0.875, 0.3764706, 0.3764706),
1699+
(0.90625, 0.3137255, 0.3137255),
1700+
(0.9375, 0.24313726, 0.24313726),
1701+
(0.96875, 0.15686275, 0.15686275),
1702+
(1.0, 0.015686275, 0.015686275)],
1703+
'blue': [
1704+
(0.0, 0.75294119, 0.75294119),
1705+
(0.03125, 0.80000001, 0.80000001),
1706+
(0.0625, 0.84313726, 0.84313726),
1707+
(0.09375, 0.88235295, 0.88235295),
1708+
(0.125, 0.91764706, 0.91764706),
1709+
(0.15625, 0.94509804, 0.94509804),
1710+
(0.1875, 0.96862745, 0.96862745),
1711+
(0.21875, 0.98431373, 0.98431373),
1712+
(0.25, 0.99607843, 0.99607843),
1713+
(0.28125, 1.0, 1.0),
1714+
(0.3125, 1.0, 1.0),
1715+
(0.34375, 0.99215686, 0.99215686),
1716+
(0.375, 0.97647059, 0.97647059),
1717+
(0.40625, 0.95686275, 0.95686275),
1718+
(0.4375, 0.93333334, 0.93333334),
1719+
(0.46875, 0.90196079, 0.90196079),
1720+
(0.5, 0.86666667, 0.86666667),
1721+
(0.53125, 0.81960785, 0.81960785),
1722+
(0.5625, 0.77254903, 0.77254903),
1723+
(0.59375, 0.72549021, 0.72549021),
1724+
(0.625, 0.67843139, 0.67843139),
1725+
(0.65625, 0.627451, 0.627451),
1726+
(0.6875, 0.58039218, 0.58039218),
1727+
(0.71875, 0.52941179, 0.52941179),
1728+
(0.75, 0.48235294, 0.48235294),
1729+
(0.78125, 0.43529412, 0.43529412),
1730+
(0.8125, 0.3882353, 0.3882353),
1731+
(0.84375, 0.34509805, 0.34509805),
1732+
(0.875, 0.3019608, 0.3019608),
1733+
(0.90625, 0.25882354, 0.25882354),
1734+
(0.9375, 0.21960784, 0.21960784),
1735+
(0.96875, 0.18431373, 0.18431373),
1736+
(1.0, 0.14901961, 0.14901961)]
1737+
}
1738+
1739+
16311740
datad = {
16321741
'afmhot': _afmhot_data,
16331742
'autumn': _autumn_data,
@@ -1700,4 +1809,4 @@ def gfunc32(x):
17001809
datad['gist_rainbow']=_gist_rainbow_data
17011810
datad['gist_stern']=_gist_stern_data
17021811
datad['gist_yarg']=_gist_yarg_data
1703-
1812+
datad['coolwarm']=_coolwarm_data

0 commit comments

Comments
 (0)