Le vendredi 08 janvier 2016, Neal Becker a ?crit :
In the following script, in the call to hexbin, I can use
ax.hexbin
or
plt.hexbin
but in the call to colorbar, I can only use
plt.colorbar
not
ax.colorbar
This seems strangely inconsistent
Because the colorbar is not attached to the axes instance, but to the
figure instance as it can illustrate any Image, ContourSet, etc... in
the figure.
The `colorbar` method lives on the figure, not the axes. This is because
making the colorbar may re-arrange the layout of the axes in the parent
figure and does not anything to the draw tree of `ax`.
# from mpl_toolkits.mplot3d import Axes3D
# from matplotlib import cm #import matplotlib as mpl
mpl.rc('font', family='sans')
fig = plt.figure()
ax = fig.add_subplot(111)
weights =
xs =
ys =
X, Y = remod_2dhist.get_axes()
for i,x in enumerate (X):
for j,y in enumerate (Y):
if remod_2dhist.buckets[i,j] != 0:
weights.append (remod_2dhist.buckets[i,j])
xs.append (x)
ys.append (y)