So far, we have visualized data by coloring each data point and have thrown in some interpolation on top. matplotlib is able to provide more sophisticated representations for 2D data. Contour lines link all points with the same value, helping you to capture features that might not be easily seen otherwise. In this recipe, we will see how to display such contour lines.
pyplot.contour() allows you to generate contour annotations. To demonstrate this, let's reuse our code from the previous recipes in order to study a zoomed-in part of the Mandelbrot set:
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): ...