I have the following python code:
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 100) y = np.linspace(0, 10, 100) X, Y = np.meshgrid(x, y, indexing='ij') Z = np.sin(X+Y) plt.pcolormesh(X, Y, Z) plt.colorbar() plt.contour(X, Y, Z, levels=[0.5, 0.75], colors=['black','cyan']) plt.show()
Which gives the following output:
I would like to place the contour marks on the colorbar, like this:
I have experimented and read up but I can’t see a way to effectively plot two quantities on the same colorbar.
Source: Python Questions