本文整理匯總了Python中matplotlib.colorbar.make_axes方法的典型用法代碼示例。如果您正苦於以下問題:Python colorbar.make_axes方法的具體用法?Python colorbar.make_axes怎麽用?Python colorbar.make_axes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.colorbar
的用法示例。
在下文中一共展示了colorbar.make_axes方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: colorbar
# 需要導入模塊: from matplotlib import colorbar [as 別名]
# 或者: from matplotlib.colorbar import make_axes [as 別名]
def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
"""
Create a colorbar for a ScalarMappable instance, *mappable*.
Documentation for the pylab thin wrapper:
%(colorbar_doc)s
"""
if ax is None:
ax = self.gca()
# Store the value of gca so that we can set it back later on.
current_ax = self.gca()
if cax is None:
if use_gridspec and isinstance(ax, SubplotBase):
cax, kw = cbar.make_axes_gridspec(ax, **kw)
else:
cax, kw = cbar.make_axes(ax, **kw)
cax.hold(True)
cb = cbar.colorbar_factory(cax, mappable, **kw)
self.sca(current_ax)
return cb
示例2: colorbar
# 需要導入模塊: from matplotlib import colorbar [as 別名]
# 或者: from matplotlib.colorbar import make_axes [as 別名]
def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
"""
Create a colorbar for a ScalarMappable instance, *mappable*.
Documentation for the pyplot thin wrapper:
%(colorbar_doc)s
"""
if ax is None:
ax = self.gca()
# Store the value of gca so that we can set it back later on.
current_ax = self.gca()
if cax is None:
if use_gridspec and isinstance(ax, SubplotBase) \
and (not self.get_constrained_layout()):
cax, kw = cbar.make_axes_gridspec(ax, **kw)
else:
cax, kw = cbar.make_axes(ax, **kw)
# need to remove kws that cannot be passed to Colorbar
NON_COLORBAR_KEYS = ['fraction', 'pad', 'shrink', 'aspect', 'anchor',
'panchor']
cb_kw = {k: v for k, v in kw.items() if k not in NON_COLORBAR_KEYS}
cb = cbar.colorbar_factory(cax, mappable, **cb_kw)
self.sca(current_ax)
self.stale = True
return cb
示例3: _post_train_batch
# 需要導入模塊: from matplotlib import colorbar [as 別名]
# 或者: from matplotlib.colorbar import make_axes [as 別名]
def _post_train_batch(self, kwargs): # pragma: no cover
if kwargs['iter'] % self._write_every == 0:
net = kwargs['net']
if self._sample is not None:
for bname in self._sample.keys():
net.blobs[bname].data[-1, ...] = self._sample[bname]
net.forward()
for bname in self._selected_blobs:
blob = net.blobs[bname].data
nchannels = blob.shape[1]
gridlen = int(_np.ceil(_np.sqrt(nchannels)))
fig, axes = _plt.subplots(nrows=gridlen,
ncols=gridlen,
squeeze=False)
bmin = blob[-1].min()
bmax = blob[-1].max()
for c_idx in range(nchannels):
ax = axes.flat[c_idx] # pylint: disable=invalid-name
im = ax.imshow(blob[-1, c_idx], # pylint: disable=invalid-name
vmin=bmin,
vmax=bmax,
cmap='Greys_r',
interpolation='none')
ax.set_title('C%d' % (c_idx))
ax.yaxis.set_visible(False)
ax.xaxis.set_visible(False)
# pylint: disable=undefined-loop-variable
for blank_idx in range(c_idx + 1, gridlen * gridlen):
ax = axes.flat[blank_idx] # pylint: disable=invalid-name
ax.axis('off')
_plt.tight_layout(rect=[0, 0.03, 1, 0.95])
_plt.suptitle("Activations in blob %s (iteration %d)" % (
bname, self._iteroffset + kwargs['iter']))
cbax, cbkw = _colorbar.make_axes([ax for ax in axes.flat])
fig.colorbar(im, cax=cbax, **cbkw)
_plt.savefig(self._output_folder +
'activations_%s_%d.png' % (
bname,
(self._iteroffset + kwargs['iter']) /
self._write_every))
_plt.close(fig)
示例4: plot_regions
# 需要導入模塊: from matplotlib import colorbar [as 別名]
# 或者: from matplotlib.colorbar import make_axes [as 別名]
def plot_regions(boxes, interests, ax=None, xlabel='', ylabel='', xlim=None, ylim=None, bar=True):
ft_off = 15
# Create figure and axes
if ax == None:
f, ax = plt.subplots(1, 1, figsize=(8, 7))
# Add the patch to the Axes
#print(boxes)
for b, ints in zip(boxes, interests):
# print(b)
lx, ly = b.low
hx, hy = b.high
c = plt.cm.jet(ints)
rect = patches.Rectangle([lx, ly], (hx - lx), (hy - ly), linewidth=3, edgecolor='white', facecolor=c)
ax.add_patch(rect)
# plt.Rectangle([lx,ly],(hx - lx), (hy - ly))
if bar:
cax, _ = cbar.make_axes(ax, shrink=0.8)
cb = cbar.ColorbarBase(cax, cmap=plt.cm.jet)
cb.set_label('Absolute Learning Progress', fontsize=ft_off + 5)
cax.tick_params(labelsize=ft_off + 0)
ax.set_xlim(left=xlim[0], right=xlim[1])
ax.set_ylim(bottom=ylim[0], top=ylim[1])
ax.set_xlabel(xlabel, fontsize=ft_off + 0)
ax.set_ylabel(ylabel, fontsize=ft_off + 0)
ax.tick_params(axis='both', which='major', labelsize=ft_off + 5)
ax.set_aspect('equal', 'box')
示例5: draw_competence_grid
# 需要導入模塊: from matplotlib import colorbar [as 別名]
# 或者: from matplotlib.colorbar import make_axes [as 別名]
def draw_competence_grid(ax, comp_grid, x_bnds, y_bnds, bar=True):
comp_grid[comp_grid == 100] = 1000
ax.pcolor(x_bnds, y_bnds, np.transpose(comp_grid),cmap=plt.cm.gray, edgecolors='k', linewidths=2,
alpha=0.3)
if bar:
cax, _ = cbar.make_axes(ax,location='left')
cb = cbar.ColorbarBase(cax, cmap=plt.cm.gray)
cb.set_label('Competence')
cax.yaxis.set_ticks_position('left')
cax.yaxis.set_label_position('left')
示例6: plot_gmm
# 需要導入模塊: from matplotlib import colorbar [as 別名]
# 或者: from matplotlib.colorbar import make_axes [as 別名]
def plot_gmm(weights, means, covariances, X=None, ax=None, xlim=[0,1], ylim=[0,1], xlabel='', ylabel='',
bar=True, bar_side='right',no_y=False, color=None):
ft_off = 15
ax = ax or plt.gca()
cmap = truncate_colormap(plt.cm.autumn_r, minval=0.2,maxval=1.0)
#colors = [plt.cm.jet(i) for i in X[:, -1]]
if X is not None:
colors = [cmap(i) for i in X[:, -1]]
sizes = [5+np.interp(i,[0,1],[0,10]) for i in X[:, -1]]
ax.scatter(X[:, 0], X[:, 1], c=colors, s=sizes, zorder=2)
#ax.axis('equal')
w_factor = 0.6 / weights.max()
for pos, covar, w in zip(means, covariances, weights):
draw_ellipse(pos, covar, alpha=0.6, ax=ax, color=color)
#plt.margins(0, 0)
ax.set_xlim(left=xlim[0], right=xlim[1])
ax.set_ylim(bottom=ylim[0], top=ylim[1])
if bar:
cax, _ = cbar.make_axes(ax, location=bar_side, shrink=0.8)
cb = cbar.ColorbarBase(cax, cmap=cmap)
cb.set_label('Absolute Learning Progress', fontsize=ft_off + 5)
cax.tick_params(labelsize=ft_off + 0)
cax.yaxis.set_ticks_position(bar_side)
cax.yaxis.set_label_position(bar_side)
#ax.yaxis.tick_right()
if no_y:
ax.set_yticks([])
else:
ax.set_ylabel(ylabel, fontsize=ft_off + 5)
#ax.yaxis.set_label_position("right")
ax.set_xlabel(xlabel, fontsize=ft_off + 5)
ax.tick_params(axis='both', which='major', labelsize=ft_off + 5)
ax.set_aspect('equal', 'box')
示例7: colorbar
# 需要導入模塊: from matplotlib import colorbar [as 別名]
# 或者: from matplotlib.colorbar import make_axes [as 別名]
def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
"""
Create a colorbar for a ScalarMappable instance, *mappable*.
Documentation for the pylab thin wrapper:
%(colorbar_doc)s
"""
if ax is None:
ax = self.gca()
# Store the value of gca so that we can set it back later on.
current_ax = self.gca()
if cax is None:
if use_gridspec and isinstance(ax, SubplotBase) \
and (not self.get_constrained_layout()):
cax, kw = cbar.make_axes_gridspec(ax, **kw)
else:
cax, kw = cbar.make_axes(ax, **kw)
cax._hold = True
# need to remove kws that cannot be passed to Colorbar
NON_COLORBAR_KEYS = ['fraction', 'pad', 'shrink', 'aspect', 'anchor',
'panchor']
cb_kw = {k: v for k, v in kw.items() if k not in NON_COLORBAR_KEYS}
cb = cbar.colorbar_factory(cax, mappable, **cb_kw)
self.sca(current_ax)
self.stale = True
return cb