Colormaps are used to map quantities stored at each point of a (discretized) surface to colours. Colours live in a 3D space. 2D data may contain metric or form information (or both). How can we choose a good colormap?
By default, we want to use a sequential colormap (not assuming anything about the structure of our data).
References:
matplotlib: http://matplotlib.org/users/colormaps.html, https://matplotlib.org/users/dflt_style_changes.htmlviscm: https://bids.github.io/colormap/
In [1]:
import pickle
In [2]:
data = pickle.load(open('data/correlation_map.pkl', 'rb'))
In [3]:
data.keys()
Out[3]:
In [4]:
type(data['excitation energy'])
Out[4]:
In [5]:
data['excitation energy'].shape
Out[5]:
In [6]:
data['correlation'].shape
Out[6]:
In [7]:
import matplotlib
%matplotlib inline
matplotlib.style.use('ggplot')
import matplotlib.pyplot as plt
In [8]:
plt.imshow(data['correlation'])
Out[8]:
Are we dealing with form or metric information here?
In [9]:
matplotlib.__version__
Out[9]:
In [10]:
from matplotlib.cm import magma, inferno, plasma, viridis
# from colormaps import magma, inferno, plasma, viridis
In [11]:
correlation = data['correlation']
excitation = data['excitation energy']
emission = data['emission energy']
In [12]:
plt.imshow(correlation,
origin='lower',
cmap=magma)
Out[12]:
In [13]:
plt.imshow(correlation,
origin='lower',
extent=[excitation.min(), excitation.max(), emission.min(), emission.max()],
cmap=magma)
Out[13]:
In [14]:
f, ax = plt.subplots(1, 1, figsize=(5, 5))
map0 = ax.imshow(correlation,
origin='lower',
extent=[excitation.min(), excitation.max(), emission.min(), emission.max()],
cmap=magma)
ax.plot(excitation, excitation)
ax.set_xlabel('Excitation Energy (eV)')
f.colorbar(map0, ax=ax)
Out[14]:
Revise and edit to best convey the scientific result.
In [15]:
f, ax = plt.subplots(1, 1, figsize=(5, 5))
ax.imshow(correlation,
origin='lower',
extent=[excitation.min(), excitation.max(), emission.min(), emission.max()],
cmap=viridis)
ax.plot(excitation, excitation)
ax.set_xlabel('Excitation Energy (eV)')
Out[15]:
What about using the new default colormap (above)?