本文整理汇总了Python中matplotlib.colorbar.ColorbarBase.set_cmap方法的典型用法代码示例。如果您正苦于以下问题:Python ColorbarBase.set_cmap方法的具体用法?Python ColorbarBase.set_cmap怎么用?Python ColorbarBase.set_cmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.colorbar.ColorbarBase
的用法示例。
在下文中一共展示了ColorbarBase.set_cmap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PanelColourBar
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_cmap [as 别名]
class PanelColourBar(wx.Panel):
def __init__(self, parent, colourMap):
wx.Panel.__init__(self, parent)
dpi = wx.ScreenDC().GetPPI()[0]
figure = matplotlib.figure.Figure(facecolor='white', dpi=dpi)
figure.set_size_inches(200.0 / dpi, 25.0 / dpi)
self.canvas = FigureCanvas(self, -1, figure)
axes = figure.add_subplot(111)
figure.subplots_adjust(0, 0, 1, 1)
norm = Normalize(vmin=0, vmax=1)
self.bar = ColorbarBase(axes, norm=norm, orientation='horizontal',
cmap=cm.get_cmap(colourMap))
axes.xaxis.set_visible(False)
def set_map(self, colourMap):
self.bar.set_cmap(colourMap)
self.bar.changed()
self.bar.draw_all()
self.canvas.draw()
示例2: Spectrogram
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_cmap [as 别名]
#.........这里部分代码省略.........
label.set_text(textMath)
label.set_visible(True)
self.axes.draw_artist(label)
def draw_measure(self, measure, show):
if self.axes.get_renderer_cache() is None:
return
self.hide_measure()
self.__clear_overflow()
if show[Measure.HBW]:
xStart, xEnd, _y = measure.get_hpw()
self.__draw_vline(Markers.HFS, xStart)
self.__draw_vline(Markers.HFE, xEnd)
if show[Measure.OBW]:
xStart, xEnd, _y = measure.get_obw()
self.__draw_vline(Markers.OFS, xStart)
self.__draw_vline(Markers.OFE, xEnd)
self.__draw_overflow()
def hide_measure(self):
for line in self.lines.itervalues():
line.set_visible(False)
for label in self.labels.itervalues():
label.set_visible(False)
for label in self.overflowLabels.itervalues():
label.set_visible(False)
def scale_plot(self, force=False):
if self.figure is not None and self.plot is not None:
extent = self.plot.get_extent()
if self.settings.autoF or force:
if extent[0] == extent[1]:
extent[1] += 1
self.axes.set_xlim(extent[0], extent[1])
if self.settings.autoL or force:
vmin, vmax = self.plot.get_clim()
self.barBase.set_clim(vmin, vmax)
try:
self.barBase.draw_all()
except:
pass
if self.settings.autoT or force:
self.axes.set_ylim(extent[2], extent[3])
def redraw_plot(self):
if self.figure is not None:
post_event(self.notify, EventThread(Event.DRAW))
def get_axes(self):
return self.axes
def get_axes_bar(self):
return self.barBase.ax
def get_plot_thread(self):
return self.threadPlot
def set_title(self, title):
self.axes.set_title(title, fontsize='medium')
def set_plot(self, spectrum, extent, annotate=False):
self.extent = extent
self.threadPlot = ThreadPlot(self, self.settings,
self.axes,
spectrum,
self.extent,
self.barBase,
annotate)
self.threadPlot.start()
def clear_plots(self):
children = self.axes.get_children()
for child in children:
if child.get_gid() is not None:
if child.get_gid() == "plot_line" or child.get_gid() == "peak":
child.remove()
def set_grid(self, on):
if on:
self.axes.grid(True, color='w')
else:
self.axes.grid(False)
self.redraw_plot()
def set_colourmap(self, colourMap):
if self.plot is not None:
self.plot.set_cmap(colourMap)
self.barBase.set_cmap(colourMap)
try:
self.barBase.draw_all()
except:
pass
def close(self):
self.figure.clear()
self.figure = None
示例3: Plotter3d
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_cmap [as 别名]
#.........这里部分代码省略.........
self.axes = self.figure.add_subplot(gs[0], projection='3d')
numformatter = ScalarFormatter(useOffset=False)
timeFormatter = DateFormatter("%H:%M:%S")
self.axes.set_xlabel("Frequency (MHz)")
self.axes.set_ylabel('Time')
self.axes.set_zlabel('Level ($\mathsf{dB/\sqrt{Hz}}$)')
colour = hex2color(self.settings.background)
colour += (1,)
self.axes.w_xaxis.set_pane_color(colour)
self.axes.w_yaxis.set_pane_color(colour)
self.axes.w_zaxis.set_pane_color(colour)
self.axes.xaxis.set_major_formatter(numformatter)
self.axes.yaxis.set_major_formatter(timeFormatter)
self.axes.zaxis.set_major_formatter(numformatter)
self.axes.xaxis.set_minor_locator(AutoMinorLocator(10))
self.axes.yaxis.set_minor_locator(AutoMinorLocator(10))
self.axes.zaxis.set_minor_locator(AutoMinorLocator(10))
self.axes.set_xlim(self.settings.start, self.settings.stop)
now = time.time()
self.axes.set_ylim(epoch_to_mpl(now), epoch_to_mpl(now - 10))
self.axes.set_zlim(-50, 0)
self.bar = self.figure.add_subplot(gs[1])
norm = Normalize(vmin=-50, vmax=0)
self.barBase = ColorbarBase(self.bar, norm=norm,
cmap=cm.get_cmap(self.settings.colourMap))
def scale_plot(self, force=False):
if self.extent is not None and self.plot is not None:
if self.settings.autoF or force:
self.axes.set_xlim(self.extent.get_f())
if self.settings.autoL or force:
self.axes.set_zlim(self.extent.get_l())
self.plot.set_clim(self.extent.get_l())
self.barBase.set_clim(self.extent.get_l())
try:
self.barBase.draw_all()
except:
pass
if self.settings.autoT or force:
self.axes.set_ylim(self.extent.get_t())
def draw_measure(self, *args):
pass
def hide_measure(self):
pass
def redraw_plot(self):
if self.figure is not None:
post_event(self.notify, EventThread(Event.DRAW))
def get_axes(self):
return self.axes
def get_axes_bar(self):
return self.barBase.ax
def get_plot_thread(self):
return self.threadPlot
def set_title(self, title):
self.axes.set_title(title, fontsize='medium')
def set_plot(self, data, extent, annotate=False):
self.extent = extent
self.threadPlot = ThreadPlot(self, self.axes,
data, self.extent,
self.settings.retainMax,
self.settings.colourMap,
self.settings.autoF,
self.barBase,
annotate)
self.threadPlot.start()
def clear_plots(self):
children = self.axes.get_children()
for child in children:
if child.get_gid() is not None:
if child.get_gid() == "plot" or child.get_gid() == "peak":
child.remove()
def set_grid(self, on):
self.axes.grid(on)
self.redraw_plot()
def set_colourmap(self, colourMap):
if self.plot is not None:
self.plot.set_cmap(colourMap)
self.barBase.set_cmap(colourMap)
try:
self.barBase.draw_all()
except:
pass
def close(self):
self.figure.clear()
self.figure = None
示例4: Plotter
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_cmap [as 别名]
#.........这里部分代码省略.........
if self.settings.autoL or force:
self.axes.set_ylim(self.extent.get_l())
if self.settings.plotFunc == PlotFunc.VAR and len(self.axes.collections) > 0:
norm = self.axes.collections[0].norm
self.barBase.set_clim((norm.vmin, norm.vmax))
else:
self.barBase.set_clim(self.extent.get_l())
norm = Normalize(vmin=self.extent.get_l()[0],
vmax=self.extent.get_l()[1])
for collection in self.axes.collections:
collection.set_norm(norm)
try:
self.barBase.draw_all()
except:
pass
def redraw_plot(self):
if self.figure is not None:
post_event(self.notify, EventThread(Event.DRAW))
def get_axes(self):
return self.axes
def get_axes_bar(self):
return self.barBase.ax
def get_plot_thread(self):
return self.threadPlot
def set_title(self, title):
self.axes.set_title(title, fontsize='medium')
def set_plot(self, spectrum, extent, annotate=False):
self.extent = extent
self.threadPlot = ThreadPlot(self, self.settings,
self.axes,
spectrum,
self.extent,
self.barBase,
annotate)
self.threadPlot.start()
return self.threadPlot
def clear_plots(self):
children = self.axes.get_children()
for child in children:
if child.get_gid() is not None:
if child.get_gid() == "plot" or child.get_gid() == "peak":
child.remove()
def set_grid(self, on):
self.axes.grid(on)
self.redraw_plot()
def set_bar(self, on):
self.barBase.ax.set_visible(on)
if on:
self.axes.change_geometry(1, 2, 1)
self.axes.get_subplotspec().get_gridspec().set_width_ratios([9.5, 0.5])
else:
self.axes.change_geometry(1, 1, 1)
self.figure.subplots_adjust()
def set_axes(self, on):
if on:
self.axes.set_axis_on()
self.bar.set_axis_on()
else:
self.axes.set_axis_off()
self.bar.set_axis_off()
def set_colourmap_use(self, on):
self.set_bar(on)
if on:
colourMap = self.settings.colourMap
else:
colourMap = ' Pure Blue'
self.set_colourmap(colourMap)
def set_colourmap(self, colourMap):
self.colourMap = colourMap
for collection in self.axes.collections:
collection.set_cmap(colourMap)
if colourMap.startswith(' Pure'):
self.bar.set_visible(False)
else:
self.bar.set_visible(True)
self.barBase.set_cmap(colourMap)
try:
self.barBase.draw_all()
except:
pass
def close(self):
self.figure.clear()
self.figure = None
示例5: __init__
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_cmap [as 别名]
#.........这里部分代码省略.........
line.set_xdata([x, x])
line.set_ydata([yLim[0], yLim[1]])
self.axes.draw_artist(line)
label.set_visible(True)
label.set_position((x, yLim[1]))
self.axes.draw_artist(label)
def draw_measure(self, background, measure, show):
if self.axes._cachedRenderer is None:
return
self.hide_measure()
canvas = self.axes.get_figure().canvas
canvas.restore_region(background)
if show[Measure.HBW]:
xStart, xEnd, _y = measure.get_hpw()
self.draw_vline(self.lineHalfFS, self.labelHalfFS, xStart)
self.draw_vline(self.lineHalfFE, self.labelHalfFE, xEnd)
if show[Measure.OBW]:
xStart, xEnd, _y = measure.get_obw()
self.draw_vline(self.lineObwFS, self.labelObwFS, xStart)
self.draw_vline(self.lineObwFE, self.labelObwFE, xEnd)
canvas.blit(self.axes.bbox)
def hide_measure(self):
self.labelHalfFS.set_visible(False)
self.labelHalfFE.set_visible(False)
self.labelObwFS.set_visible(False)
self.labelObwFE.set_visible(False)
def scale_plot(self, force=False):
if self.figure is not None and self.plot is not None:
extent = self.plot.get_extent()
if self.settings.autoF or force:
if extent[0] == extent[1]:
extent[1] += 1
self.axes.set_xlim(extent[0], extent[1])
if self.settings.autoL or force:
vmin, vmax = self.plot.get_clim()
self.barBase.set_clim(vmin, vmax)
try:
self.barBase.draw_all()
except:
pass
if self.settings.autoT or force:
self.axes.set_ylim(extent[2], extent[3])
def redraw_plot(self):
if self.figure is not None:
post_event(self.notify, EventThreadStatus(Event.DRAW))
def get_axes(self):
return self.axes
def get_plot_thread(self):
return self.threadPlot
def set_title(self, title):
self.axes.set_title(title)
def set_plot(self, data, extent, annotate=False):
self.extent = extent
self.threadPlot = ThreadPlot(self, self.axes,
data, self.extent,
self.settings.retainMax,
self.settings.colourMap,
self.settings.autoL,
self.barBase,
annotate)
self.threadPlot.start()
def clear_plots(self):
children = self.axes.get_children()
for child in children:
if child.get_gid() is not None:
if child.get_gid() == "plot" or child.get_gid() == "peak":
child.remove()
def set_grid(self, on):
if on:
self.axes.grid(True, color='w')
else:
self.axes.grid(False)
self.redraw_plot()
def set_colourmap(self, colourMap):
if self.plot is not None:
self.plot.set_cmap(colourMap)
self.barBase.set_cmap(colourMap)
try:
self.barBase.draw_all()
except:
pass
def close(self):
self.figure.clear()
self.figure = None
示例6: Plotter
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_cmap [as 别名]
#.........这里部分代码省略.........
if show[Measure.HBW]:
xStart, xEnd, y = measure.get_hpw()
self.draw_hline(self.lineHalfP, self.labelHalfP, y)
self.draw_vline(self.lineHalfFS, self.labelHalfFS, xStart)
self.draw_vline(self.lineHalfFE, self.labelHalfFE, xEnd)
if show[Measure.OBW]:
xStart, xEnd, y = measure.get_obw()
self.draw_hline(self.lineObwP, self.labelObwP, y)
self.draw_vline(self.lineObwFS, self.labelObwFS, xStart)
self.draw_vline(self.lineObwFE, self.labelObwFE, xEnd)
canvas.blit(self.axes.bbox)
def hide_measure(self):
self.lineMinP.set_visible(False)
self.lineMaxP.set_visible(False)
self.lineAvgP.set_visible(False)
self.lineGMP.set_visible(False)
self.lineHalfP.set_visible(False)
self.lineHalfFS.set_visible(False)
self.lineHalfFE.set_visible(False)
self.lineObwP.set_visible(False)
self.lineObwFS.set_visible(False)
self.lineObwFE.set_visible(False)
self.labelMinP.set_visible(False)
self.labelMaxP.set_visible(False)
self.labelAvgP.set_visible(False)
self.labelGMP.set_visible(False)
self.labelHalfP.set_visible(False)
self.labelHalfFS.set_visible(False)
self.labelHalfFE.set_visible(False)
self.labelObwP.set_visible(False)
self.labelObwFS.set_visible(False)
self.labelObwFE.set_visible(False)
def scale_plot(self, force=False):
if self.extent is not None:
if self.settings.autoF or force:
self.axes.set_xlim(self.extent.get_f())
if self.settings.autoL or force:
self.axes.set_ylim(self.extent.get_l())
self.barBase.set_clim(self.extent.get_l())
norm = Normalize(vmin=self.extent.get_l()[0],
vmax=self.extent.get_l()[1])
for collection in self.axes.collections:
collection.set_norm(norm)
try:
self.barBase.draw_all()
except:
pass
def redraw_plot(self):
if self.figure is not None:
post_event(self.notify, EventThreadStatus(Event.DRAW))
def get_axes(self):
return self.axes
def get_plot_thread(self):
return self.threadPlot
def set_title(self, title):
self.axes.set_title(title)
def set_plot(self, spectrum, extent, annotate=False):
self.extent = extent
self.threadPlot = ThreadPlot(self, self.axes, spectrum,
self.extent,
self.settings.colourMap,
self.settings.autoL,
self.settings.lineWidth,
self.barBase,
self.settings.fadeScans,
annotate, self.settings.average)
self.threadPlot.start()
def clear_plots(self):
children = self.axes.get_children()
for child in children:
if child.get_gid() is not None:
if child.get_gid() == "plot" or child.get_gid() == "peak":
child.remove()
def set_grid(self, on):
self.axes.grid(on)
self.redraw_plot()
def set_colourmap(self, colourMap):
for collection in self.axes.collections:
collection.set_cmap(colourMap)
self.barBase.set_cmap(colourMap)
try:
self.barBase.draw_all()
except:
pass
def close(self):
self.figure.clear()
self.figure = None
示例7: WidgetPlot
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_cmap [as 别名]
class WidgetPlot(FigureCanvas):
def __init__(self, parent=None):
FigureCanvas.__init__(self, Figure())
self._telemetry = None
self._resolution = None
self._cmap = None
self._wireframe = False
self.setParent(parent)
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self.setFocus()
colour = self.palette().color(self.backgroundRole()).getRgbF()
self.figure.patch.set_facecolor(colour[:-1])
gs = GridSpec(1, 2, width_ratios=[9.5, 0.5])
self._axes = self.figure.add_subplot(gs[0], projection='3d')
self._axes.set_title('3D Plot')
self._axes.set_xlabel('Longitude')
self._axes.set_ylabel('Latitude')
self._axes.set_zlabel('Level (dB)')
self._axes.tick_params(axis='both', which='major', labelsize='smaller')
self._axes.grid(True)
formatMaj = ScalarFormatter(useOffset=False)
self._axes.xaxis.set_major_formatter(formatMaj)
self._axes.yaxis.set_major_formatter(formatMaj)
self._axes.zaxis.set_major_formatter(formatMaj)
formatMinor = AutoMinorLocator(10)
self._axes.xaxis.set_minor_locator(formatMinor)
self._axes.yaxis.set_minor_locator(formatMinor)
self._axes.zaxis.set_minor_locator(formatMinor)
self._axesBar = self.figure.add_subplot(gs[1])
self._axesBar.tick_params(axis='both', which='major',
labelsize='smaller')
self._bar = ColorbarBase(self._axesBar)
if matplotlib.__version__ >= '1.2':
self.figure.tight_layout()
def set(self, telemetry):
self._telemetry = telemetry
def set_cmap(self, cmap):
self._cmap = cmap
def set_resolution(self, res):
self._resolution = res
def set_wireframe(self, wireframe):
self._wireframe = wireframe
def plot(self, interpolation):
self.clear()
x, y, z = unique_locations(self._telemetry)
east = max(x)
west = min(x)
north = max(y)
south = min(y)
width = east - west
height = north - south
if width != 0 and height != 0:
xi = numpy.linspace(west, east, self._resolution)
yi = numpy.linspace(south, north, self._resolution)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
xSurf, ySurf = numpy.meshgrid(xi, yi)
zSurf = mlab.griddata(x, y, z, xi=xi, yi=yi,
interp=interpolation)
vmin = numpy.min(zSurf)
vmax = numpy.max(zSurf)
zSurf[numpy.where(numpy.ma.getmask(zSurf) == True)] = vmin
zSurf.mask = False
if self._wireframe:
self._axes.plot_wireframe(xSurf, ySurf, zSurf,
linewidth=0.5,
gid='plot')
self._axesBar.set_visible(False)
else:
self._axes.plot_surface(xSurf, ySurf, zSurf,
vmin=vmin, vmax=vmax,
rstride=1, cstride=1,
linewidth=0.1,
cmap=self._cmap,
gid='plot')
self._bar.set_cmap(self._cmap)
self._bar.set_clim(vmin, vmax)
self._axesBar.set_ylim(vmin, vmax)
self._axesBar.set_visible(True)
self.draw()
#.........这里部分代码省略.........