本文整理汇总了Python中matplotlib.colorbar.ColorbarBase.set_ticks方法的典型用法代码示例。如果您正苦于以下问题:Python ColorbarBase.set_ticks方法的具体用法?Python ColorbarBase.set_ticks怎么用?Python ColorbarBase.set_ticks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.colorbar.ColorbarBase
的用法示例。
在下文中一共展示了ColorbarBase.set_ticks方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pic_switch
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_ticks [as 别名]
def pic_switch(event):
bounds = roi1.export()
if zoom.value_selected == 'Zoom':
axpic.cla()
axpic.imshow(start.pic_list[int(pic_swap.val)], vmin=vmin.val, vmax=vmax.val, cmap=gray.value_selected)
axpic.set_title(start.file_list[int(pic_swap.val)])
axpic.set_xlim(bounds[2], bounds[3])
axpic.set_ylim(bounds[1], bounds[0])
axpic.axvline(x=bounds[2])
axpic.axvline(x=bounds[3])
axpic.axhline(y=bounds[0])
axpic.axhline(y=bounds[1])
axbar.cla()
norm = Normalize(vmin=vmin.val, vmax=vmax.val)
col = ColorbarBase(axbar, cmap=gray.value_selected, norm=norm, orientation='horizontal')
col.set_ticks([vmin.val, vmax.val], update_ticks=True)
else:
axpic.cla()
axpic.imshow(start.pic_list[int(pic_swap.val)], vmin=vmin.val, vmax=vmax.val, cmap=gray.value_selected)
axpic.set_title(start.file_list[int(pic_swap.val)])
axpic.axvline(x=bounds[2])
axpic.axvline(x=bounds[3])
axpic.axhline(y=bounds[0])
axpic.axhline(y=bounds[1])
axbar.cla()
norm = Normalize(vmin=vmin.val, vmax=vmax.val)
col = ColorbarBase(axbar, cmap=gray.value_selected, norm=norm, orientation='horizontal')
col.set_ticks([vmin.val, vmax.val], update_ticks=True)
示例2: spikesplot_cb
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_ticks [as 别名]
def spikesplot_cb(position, cmap='viridis', fig=None):
# Add colorbar
if fig is None:
fig = plt.gcf()
cax = fig.add_axes(position)
cb = ColorbarBase(cax, cmap=get_cmap(cmap), spacing='proportional',
orientation='horizontal', drawedges=False)
cb.set_ticks([0, 0.5, 1.0])
cb.set_ticklabels(['Inferior', '(axial slice)', 'Superior'])
cb.outline.set_linewidth(0)
cb.ax.xaxis.set_tick_params(width=0)
return cax
示例3: display_median_price_animation
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_ticks [as 别名]
def display_median_price_animation(self):
"""Kicks off the animation of median price information."""
fig = plotter.figure(num = 1, figsize = (10, 12), tight_layout = True)
fig.canvas.set_window_title('Percent increase in median house ' + \
'price since 1996')
axis = fig.add_axes([0.85, 0.04, 0.03, 0.92])
colorbar_ticks = [0, .2, .4, .6, .8, 1.0]
colorbar_labels = ['-100%', '0%', '250%', '500%', '750%', '>1000%']
colorbar = ColorbarBase(axis, self._colormap, orientation='vertical')
colorbar.set_ticks(colorbar_ticks)
colorbar.set_ticklabels(colorbar_labels)
fig.add_axes([0.0, 0.0, 0.82, 1.0])
anim = FuncAnimation(fig,
self._animate,
frames = self.endyear + 1 - self.startyear,
interval = 1000,
blit = True,
init_func = self._init_animate,
repeat_delay = 3000)
plotter.show()
示例4: create_multipanel_plot
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_ticks [as 别名]
def create_multipanel_plot(size, dpi, shape, layout, var_info, cmap, lims):
fig = plt.figure(figsize=size, dpi=dpi)
rings = []
# the rect parameter will be ignore as we will set axes_locator
rect = (0.08, 0.08, 0.9, 0.9)
nrow,ncol = shape
# divide the axes rectangle into grid whose size is specified
# by horiz * vert
horiz = [Scaled(1.)]
for i in range(ncol - 1):
horiz.extend([Fixed(.2), Scaled(1.)])
vert = [Scaled(.1), Fixed(.35), Scaled(1.)]
for i in range(nrow - 1):
vert.extend([Fixed(.1), Scaled(1.)])
divider = Divider(fig, rect, horiz, vert, aspect=False)
# ax0 = fig.add_axes(rect, label="0")
# ax0.set_aspect('equal', 'datalim')
# ax = [ax0] + [fig.add_axes(rect, label="%d"%i, sharex=ax0, sharey=ax0)
# for i in range(1,6)]
ax = [fig.add_axes(rect, label="%d"%i) for i in range(len(layout))]
cax = [fig.add_axes(rect, label='cb%d'%i) for i in range(ncol)]
for i,a in enumerate(ax):
# a.set_axes_locator(divider.new_locator(nx=(i // nrow) * 2,
# ny=((i%nrow) + 1) * 2))
a.set_axes_locator(divider.new_locator(nx=(i % ncol) * 2,
ny=(nrow - (i // ncol)) * 2))
a.set_aspect('equal', 'datalim')
for i,a in enumerate(cax):
a.set_axes_locator(divider.new_locator(nx=2 * i, ny=0))
for num,(a,(data, label, var)) in enumerate(zip(ax, layout)):
norm,ticks,units = var_info[var]
ppi_plot(init_data.xlocs, init_data.ylocs, data, norm=norm,
cmap=cmap, ax=a, rings=rings)
# a.set_title('%s (%s)' % (moment, units))
if num >= ncol:
a.set_xlabel('X Distance (km)')
cbar = ColorbarBase(ax=cax[num%ncol], norm=norm, cmap=cmap,
orientation='horizontal')
cbar.set_label('%s (%s)' % (label, units))
cbar.set_ticks(ticks)
else:
a.xaxis.set_major_formatter(plt.NullFormatter())
if num % ncol == 0:
a.set_ylabel('Y Distance (km)')
else:
a.yaxis.set_major_formatter(plt.NullFormatter())
if lims:
a.xaxis.set_major_locator(plt.MultipleLocator(lims[0]))
a.yaxis.set_major_locator(plt.MultipleLocator(lims[0]))
a.set_xlim(*lims[1:3])
a.set_ylim(*lims[3:])
# loc = 2 is upper left. TODO: Should patch matplotlib to use
# same strings as legend
at = AnchoredText("%s)" % chr(97 + num), loc=2, prop=dict(size='large'),
frameon=True)
# at.patch.set_boxstyle("round, pad=0., rounding_size=0.2")
a.add_artist(at)
return fig