March 2014
Beginner to intermediate
222 pages
4h 7m
English
A colormap is a key ingredient to produce both readable and visually pleasing figures. However, we are doing science here, and esthetic is just a side objective. When using colormaps, we would like to know which value corresponds to a given color. In this recipe, we will look at a simple way to add such information to a figure.
We will use the same example, the Mandelbrot set. We simply add a call to pyplot.colorbar():
import numpy as np from matplotlib import pyplot as plt import matplotlib.cm as cm def iter_count(C, max_iter): X = C for n in range(max_iter): if abs(X) > 2.: return n X = X ** 2 + C return max_iter N = 512 max_iter = 64 xmin, xmax, ymin, ymax = -2.2, .8, -1.5, 1.5 X = np.linspace(xmin, ...
Read now
Unlock full access