I want to do something similar to http://matplotlib.org/examples/pylab_examples/hist2d_log_demo.html , but I read that using pylab for code other than python interactive mode is bad so I would like to do it with using matplotlib.pyplot. However, I cannot figure out how to make this code work with pyplot. Using, pylab, an example
from matplotlib.colors import LogNorm from pylab import *
I tried a lot
import matplotlib.pyplot as plt fig = plt.figure() ax1 = fig.add_subplot(1,1,1) h1 = ax1.hist2d([1,2],[3,4])
and from here I tried everything: from plt.colorbar(h1) plt.colorbar(ax1) plt.colorbar(fig) ax.colorbar() , etc. etc., and I cannot get anything to work.
In general, I honestly donβt quite understand the connection between pylab and pyplot, even after reading http://matplotlib.org/faq/usage_faq.html . For example, show() in pylab seems to become plt.show() in pyplot, but somehow the colorbar does not become plt.colorbar() ?
For instance,
source share