本文整理汇总了Python中matplotlib.colorbar.ColorbarBase.draw_all方法的典型用法代码示例。如果您正苦于以下问题:Python ColorbarBase.draw_all方法的具体用法?Python ColorbarBase.draw_all怎么用?Python ColorbarBase.draw_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.colorbar.ColorbarBase
的用法示例。
在下文中一共展示了ColorbarBase.draw_all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PanelColourBar
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import draw_all [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 draw_all [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 draw_all [as 别名]
class Plotter3d():
def __init__(self, notify, figure, settings):
self.notify = notify
self.figure = figure
self.settings = settings
self.axes = None
self.bar = None
self.barBase = None
self.plot = None
self.extent = None
self.threadPlot = None
self.wireframe = settings.wireframe
self.__setup_plot()
self.set_grid(settings.grid)
def __setup_plot(self):
gs = GridSpec(1, 2, width_ratios=[9.5, 0.5])
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()
#.........这里部分代码省略.........
示例4: Plotter
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import draw_all [as 别名]
#.........这里部分代码省略.........
if show[Measure.OBW]:
xStart, xEnd, y = measure.get_obw()
self.__draw_hline(Markers.OP, y)
self.__draw_vline(Markers.OFE, 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.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())
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):
示例5: __init__
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import draw_all [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 draw_all [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: draw
# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import draw_all [as 别名]
def draw( self ):
PlotBase.draw( self )
self.x_formatter_cb( self.ax )
if self.gdata.isEmpty():
return None
tmp_x = []; tmp_y = []
# Evaluate the bar width
width = float( self.width )
offset = 0.
if self.gdata.key_type == 'time':
width = width / 86400.0
start_plot = 0
end_plot = 0
if "starttime" in self.prefs and "endtime" in self.prefs:
start_plot = date2num( datetime.datetime.fromtimestamp( to_timestamp( self.prefs['starttime'] ) ) )
end_plot = date2num( datetime.datetime.fromtimestamp( to_timestamp( self.prefs['endtime'] ) ) )
labels = self.gdata.getLabels()
nKeys = self.gdata.getNumberOfKeys()
tmp_b = []
tmp_x = []
tmp_y = []
self.bars = []
labels = self.gdata.getLabels()
nLabel = 0
labelNames = []
colors = []
xmin = None
xmax = None
for label, num in labels:
labelNames.append( label )
for key, value in self.gdata.getPlotNumData( label ):
if xmin is None or xmin > ( key + offset ):
xmin = key + offset
if xmax is None or xmax < ( key + offset ):
xmax = key + offset
if value is not None:
colors.append( self.getQualityColor( value ) )
tmp_x.append( key + offset )
tmp_y.append( 1. )
tmp_b.append( float( nLabel ) )
nLabel += 1
self.bars += self.ax.bar( tmp_x, tmp_y, bottom = tmp_b, width = width, color = colors )
dpi = self.prefs.get( 'dpi', 100 )
setp( self.bars, linewidth = pixelToPoint( 0.5, dpi ), edgecolor = '#AAAAAA' )
#pivots = keys
#for idx in range(len(pivots)):
# self.coords[ pivots[idx] ] = self.bars[idx]
ymax = float( nLabel )
self.ax.set_xlim( xmin = 0., xmax = xmax + width + offset )
self.ax.set_ylim( ymin = 0., ymax = ymax )
if self.gdata.key_type == 'time':
if start_plot and end_plot:
self.ax.set_xlim( xmin = start_plot, xmax = end_plot )
else:
self.ax.set_xlim( xmin = min( tmp_x ), xmax = max( tmp_x ) )
self.ax.set_yticks( [ i + 0.5 for i in range( nLabel ) ] )
self.ax.set_yticklabels( labelNames )
setp( self.ax.get_xticklines(), markersize = 0. )
setp( self.ax.get_yticklines(), markersize = 0. )
cax, kw = make_axes( self.ax, orientation = 'vertical', fraction = 0.07 )
cb = ColorbarBase( cax, cmap = cm.RdYlGn, norm = self.norms )
cb.draw_all()