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


Python SubplotHost.set_yscale方法代码示例

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


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

示例1: MatplotlibTimelines

# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_yscale [as 别名]

#.........这里部分代码省略.........
            self.axis1.set_autoscalex_on(False)
            if self.axis2:
                self.axis2.set_xbound(lower=start,upper=end)
                self.axis2.set_autoscalex_on(False)

        drawstyle='default'
        marker=''
        linestyle='-'

        if self.with_=='lines':
            pass
        elif self.with_=='steps':
            drawstyle='steps'
        elif self.with_=='points':
            linestyle=''
            marker='*'
        elif self.with_=='dots':
            linestyle=''
            marker='.'
        elif self.with_=='linespoints':
            marker='*'
        else:
            warning("'with'-style",self.with_,"not implemented, using 'lines'")

        if plotIt:
            a.plot(tm,
                   data,
                   label=title,
                   drawstyle=drawstyle,
                   marker=marker,
                   linestyle=linestyle)

    def preparePlot(self):
        """Prepare the plotting window"""
        plt.hot()
        self.figure=plt.figure(self.figNr)
        self.figure.clear()
        # this is black magic that makes the legend work with two axes
        if self.hasSubplotHost:
            self.axis1=SubplotHost(self.figure,111)
            self.figure.add_subplot(self.axis1)
        else:
            self.axis1=self.figure.add_subplot(111)
        self.axis1.set_xlabel(self.xlabel)
        self.axis1.set_ylabel(self.ylabel)

        if len(self.alternate)>0:
            self.axis2=self.axis1.twinx()
            self.axis2.set_ylabel(self.ylabel2)

        try:
            if self.spec.logscale:
                self.axis1.set_yscale("log")
                if self.axis2:
                    self.axis2.set_yscale("log")
        except AttributeError:
            pass

    def doReplot(self):
        """Replot the whole data"""

        if self.hasSubplotHost:
            l=self.axis1.legend(fancybox=True)
        else:
            l=plt.legend(fancybox=True)
        #         l.get_frame().set_fill(False)
        if l:
            l.get_frame().set_alpha(0.7)
            l.get_texts()[0].set_size(10)
        plt.suptitle(self.title)
        plt.grid(True)
        plt.draw()
        #  plt.show()

    def actualSetTitle(self,title):
        """Sets the title"""

        self.title=title

    def setXLabel(self,title):
        """Sets the label on the X-Axis"""

        self.xlabel=title

    def setYLabel(self,title):
        """Sets the label on the first Y-Axis"""

        self.ylabel=title

    def setYLabel2(self,title):
        """Sets the label on the second Y-Axis"""

        self.ylabel2=title

    def doHardcopy(self,filename,form):
        """Write the contents of the plot to disk
        @param filename: Name of the file without type extension
        @param form: String describing the format"""

        self.figure.savefig(filename+"."+form,format=form)
开发者ID:martinep,项目名称:foam-extend-svn,代码行数:104,代码来源:MatplotlibTimelines.py

示例2: temperature

# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_yscale [as 别名]
from scipy.constants import physical_constants
kB=physical_constants['Boltzmann constant in eV/K'][0]

import numpy as np
arange=np.arange
exp=np.exp

tt=arange(18.,501.)
vv=exp(-0.02/(kB*tt))

import matplotlib.pylab as plt
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost

fig=plt.figure(1)
ax1=SubplotHost(fig, 111)
fig.add_subplot(ax1)

ax1.plot(1./tt,vv)
ax1.set_yscale('log')
ax1.set_xlabel('Reciprocal temperature (1/K)')

ax2=ax1.twin() # ax2 is responsible for "top" axis and "right" axis
tticks=np.array([20.,30.,50.,100.,300.])
ax2.set_xticks( [ 1/t for t in tticks ] )
ax2.set_xticklabels(tticks)
ax2.axis["top"].label.set_visible(True)
ax2.set_xlabel('Temperature (K)')
ax2.set_yticks([])

plt.show()
开发者ID:gmassei,项目名称:bastelpython,代码行数:32,代码来源:arrhenius-plot2.py


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