当前位置: 首页>>代码示例>>Python>>正文


Python ColorbarBase.set_clim方法代码示例

本文整理汇总了Python中matplotlib.colorbar.ColorbarBase.set_clim方法的典型用法代码示例。如果您正苦于以下问题:Python ColorbarBase.set_clim方法的具体用法?Python ColorbarBase.set_clim怎么用?Python ColorbarBase.set_clim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.colorbar.ColorbarBase的用法示例。


在下文中一共展示了ColorbarBase.set_clim方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Spectrogram

# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_clim [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
开发者ID:har5ha,项目名称:RTLSDR-Scanner,代码行数:104,代码来源:plot_spect.py

示例2: Plotter3d

# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_clim [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()
#.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:RTLSDR-Scanner,代码行数:103,代码来源:plot3d.py

示例3: Plotter

# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_clim [as 别名]

#.........这里部分代码省略.........
            y = measure.get_gmean_p()
            self.__draw_hline(Markers.GMEAN, y)

        if show[Measure.HBW]:
            xStart, xEnd, y = measure.get_hpw()
            self.__draw_hline(Markers.HP, y)
            self.__draw_vline(Markers.HFS, xStart)
            self.__draw_vline(Markers.HFE, xEnd)

        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,
开发者ID:thatchristoph,项目名称:RTLSDR-Scanner,代码行数:70,代码来源:plot_line.py

示例4: __init__

# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_clim [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
开发者ID:vlslv,项目名称:RTLSDR-Scanner,代码行数:104,代码来源:spectrogram.py

示例5: Plotter

# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_clim [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
开发者ID:vlslv,项目名称:RTLSDR-Scanner,代码行数:104,代码来源:plot.py

示例6: WidgetPlot

# 需要导入模块: from matplotlib.colorbar import ColorbarBase [as 别名]
# 或者: from matplotlib.colorbar.ColorbarBase import set_clim [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()
#.........这里部分代码省略.........
开发者ID:EarToEarOak,项目名称:Wild-Find,代码行数:103,代码来源:plot3d.py


注:本文中的matplotlib.colorbar.ColorbarBase.set_clim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。