import matplotlib.pyplot as plt
plt.rcParams['svg.fonttype'] = 'none'
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('svg')
# # in newer versions of IPython, use
# import matplotlib_inline.backend_inline
# matplotlib_inline.backend_inline.set_matplotlib_formats('svg')
from tol_colors import tol_cmap, tol_cset
import numpy as np
from scipy.stats import multivariate_normal
# generate some dummy data
line_x = np.linspace(0, 2*np.pi, 100)
line_ys = [np.sin(line_x + i * np.pi / 6.0) for i in range(4)]
scatter_data = [np.random.normal(0, i+1, size=(40, 2)) for i in range(4)]
heatmap_t = np.linspace(-2, 2, 100)
heatmap_xs, heatmap_ys = np.meshgrid(heatmap_t, heatmap_t)
heatmap_data1 = multivariate_normal.pdf(np.dstack([heatmap_xs, heatmap_ys]), mean=np.zeros(2), cov=np.eye(2))
heatmap_data2 = np.sinc(heatmap_xs) * np.sinc(heatmap_ys)
cmap = tol_cset('bright')
for i in range(len(line_ys)):
plt.plot(line_x, line_ys[i], color=cmap[i], label=f'Label {i+1}')
plt.legend(bbox_to_anchor=(1.02,0.9))
plt.title('quantitative colors (bright)')
plt.show()
cmap = tol_cset('muted')
for i in range(len(scatter_data)):
data = scatter_data[i]
plt.scatter(data[:, 0], data[:, 1], color=cmap[i], s=2, label=f'Label {i+1}')
plt.legend(bbox_to_anchor=(1.02,0.9))
plt.title('quantitative colors (muted)')
plt.show()
cmap = tol_cmap('sunset')
plt.imshow(heatmap_data2, cmap=cmap)
plt.colorbar()
plt.title('diverging colormap (sunset)')
plt.show()
cmap = tol_cmap('PRGn')
plt.imshow(heatmap_data1, cmap=cmap)
plt.colorbar()
plt.title('diverging colormap (sunset)')
plt.show()
cmap = tol_cmap('YlOrBr')
plt.imshow(heatmap_data2, cmap=cmap)
plt.colorbar()
plt.title('sequential colormap (YlOrBr)')
plt.show()
cmap = tol_cmap('iridescent')
plt.imshow(heatmap_data1, cmap=cmap)
plt.colorbar()
plt.title('sequential colormap (iridescent)')
plt.show()