|
From: zetah <ot...@hu...> - 2013-06-13 21:09:17
|
Hi, in this example: ======================================== import numpy as np import matplotlib.pyplot as plt arr = np.random.random((10, 10)) plt.contourf(arr, 10) plt.contourf(arr, 10, cmap='coolwarm', levels=np.arange(0, 1, .2), alpha=.5) plt.colorbar() plt.show() ======================================== colorbar is representing last contour. I want to make colorbar that will match actual plot, which is combination of two contours obviously. I tried also something like: ======================================== import numpy as np import matplotlib.pyplot as plt arr = np.random.random((10, 10)) fig = plt.figure() ax = fig.add_subplot(111) cax = ax.contourf(arr, 10) cb = fig.colorbar(cax) cax = ax.contourf(arr, 10, cmap='coolwarm', levels=np.arange(0, 1, .2), alpha=.5) cb.update_bruteforce(cax) # tried also: cb.update_normal(cax) plt.show() ======================================== but it didn't get me there. Is there some easy way to do this? Thanks |