Python matplotlib.ticker 模块,FixedFormatter() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用matplotlib.ticker.FixedFormatter()

项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def set_ticklabels(self, ticklabels, update_ticks=True):
        """
        set tick labels. Tick labels are updated immediately unless
        update_ticks is *False*. To manually update the ticks, call
        *update_ticks* method explicitly.
        """
        if isinstance(self.locator, ticker.FixedLocator):
            self.formatter = ticker.FixedFormatter(ticklabels)
            if update_ticks:
                self.update_ticks()
        else:
            warnings.warn("set_ticks() must have been called.")
项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def set_ticklabels(self, ticklabels, update_ticks=True):
        """
        set tick labels. Tick labels are updated immediately unless
        update_ticks is *False*. To manually update the ticks, call
        *update_ticks* method explicitly.
        """
        if isinstance(self.locator, ticker.FixedLocator):
            self.formatter = ticker.FixedFormatter(ticklabels)
            if update_ticks:
                self.update_ticks()
        else:
            warnings.warn("set_ticks() must have been called.")
项目:TMV3    作者:HenricusRex    | 项目源码 | 文件源码
def setLineSensor(self):
        try:
            self.compressLabel(self.sensorList)

            x1=[]
            x1pos=[]
            labels1=[]

            j = -1
            x1pos.append(0)
            labels1.append('')
           # self.setTestData()
            for i in self.sensorList:
                if i.startX > j:
                    x1.append(i.startX)
                    j = i.startX
                    x1.append(i.stopX)
                    x1pos.append(i.labelPos)
                    labels1.append(i.label)


            self.par1.xaxis.set_major_formatter(ticker.NullFormatter())
            self.par1.xaxis.set_minor_locator(ticker.FixedLocator(x1pos))
            self.par1.xaxis.set_minor_formatter(ticker.FixedFormatter(labels1))
            self.par1.xaxis.set_ticks(x1)

        except Exception as _err:
            print(_err)
            logging.exception(_err)
            pass
项目:TMV3    作者:HenricusRex    | 项目源码 | 文件源码
def setLineRBW(self):

        self.compressLabel(self.rbwList)

        try:
            x1 = []
            x1pos = []
            labels1 = []
            j = -1
            x1pos.append(0)
            labels1.append('')
           # self.setTestData()
            for i in self.rbwList:
                if i.startX > j:
                    x1.append(i.startX)
                    j = i.startX
                x1.append(i.stopX)
                x1pos.append(i.labelPos)
                labels1.append(i.label)

         #   self.par2.spines["bottom"].set_position(("outward", 50))
         #   self.par2.xaxis.set_ticks_position('bottom')
#            self.par2.set_xscale('log')
            self.par2.xaxis.set_major_formatter(ticker.NullFormatter())
            self.par2.xaxis.set_minor_locator(ticker.FixedLocator(x1pos))
            self.par2.xaxis.set_minor_formatter(ticker.FixedFormatter(labels1))
            self.par2.xaxis.set_ticks(x1)
            self.par2.xaxis.set_tick_params(which='minor',length=1,direction='out', pad=5, labelbottom='on')
            self.par2.xaxis.set_tick_params(which='major',length=10,direction='out', pad=5,labelbottom='on')

        except Exception as _err:
            print(_err)
            logging.exception(_err)
项目:TMV3    作者:HenricusRex    | 项目源码 | 文件源码
def setLineAMP(self):

        self.compressLabel(self.ampList)

        try:
            x1 = []
            x1pos = []
            labels1 = []
            j = -1
            x1pos.append(0)
            labels1.append('')
           # self.setTestData()
            for i in self.ampList:
                if i.startX > j:
                    x1.append(i.startX)
                    j = i.startX
                x1.append(i.stopX)
                x1pos.append(i.labelPos)
                labels1.append(i.label)


            if not self.line2TextFlag:
                # self.par3.text(-0.05,-0.33,"amp",horizontalalignment='left',transform=self.host.transAxes)
                # self.par3.text(-0.05,-0.40,"att",horizontalalignment='left',transform=self.host.transAxes)
               #  self.par3.spines["bottom"].set_position(("outward", 90))
                 self.par3.xaxis.set_ticks_position('bottom')
                 self.par3.xaxis.set_major_formatter(ticker.NullFormatter())
                 self.par3.xaxis.set_minor_formatter(ticker.NullFormatter())
                 self.par3.xaxis.set_tick_params(which='minor',length=1,direction='in', pad=-10, labelbottom='on')
                 self.par3.xaxis.set_tick_params(which='major',length=10,direction='in', pad=-20,labelbottom='on')
                 self.line2TextFlag = True

            self.par3.xaxis.set_minor_locator(ticker.FixedLocator(x1pos))
            self.par3.xaxis.set_minor_formatter(ticker.FixedFormatter(labels1))
            self.par3.xaxis.set_ticks(x1)

            #set color for autorange indication
            _Ret = self.par3.xaxis.get_minorticklabels()
            n = 0
            for i in _Ret:
                if self.ampList[n].color =='r':
                    i._color = 'r' #sorry, found no other access
                if n < len(self.ampList) - 1:
                    n += 1
        except Exception as _err:
            print(_err)
            logging.exception(_err)
        pass
项目:TMV3    作者:HenricusRex    | 项目源码 | 文件源码
def setLineATT(self):

        self.compressLabel(self.attList)

        try:
            x1 = []
            x1pos = []
            labels1 = []
            j = -1
            x1pos.append(0)
            labels1.append('')
           # self.setTestData()
            for i in self.attList:
                if i.startX > j:
                    x1.append(i.startX)
                    j = i.startX
                x1.append(i.stopX)
                x1pos.append(i.labelPos)
                labels1.append(i.label)


       #     self.par4.spines["bottom"].set_position(("outward", 90))
       #     self.par4.xaxis.set_ticks_position('bottom')
           # # self.par1.set_xlim(1e3,1e9)
           #  self.par4.set_xscale('log')
            self.par4.xaxis.set_major_formatter(ticker.NullFormatter())
            self.par4.xaxis.set_minor_locator(ticker.FixedLocator(x1pos))
            self.par4.xaxis.set_minor_formatter(ticker.FixedFormatter(labels1))
            self.par4.xaxis.set_ticks(x1)
            self.par4.xaxis.set_tick_params(which='minor',length=1,direction='out', pad=5, labelbottom='on')
            self.par4.xaxis.set_tick_params(which='major',length=10,direction='out', pad=5,labelbottom='on')

            _Ret = self.par4.xaxis.get_minorticklabels()
            n = 0
            for i in _Ret:
                if self.attList[n].color =='r':
                    i._color = 'red'
                if n < len(self.attList) - 1:
                    n += 1

          #  self.signalGraphUpdate.emit()
        except Exception as _err:
            print(_err)
            logging.exception(_err)
        pass