本文整理汇总了Python中mpl_toolkits.axes_grid.parasite_axes.SubplotHost.twin方法的典型用法代码示例。如果您正苦于以下问题:Python SubplotHost.twin方法的具体用法?Python SubplotHost.twin怎么用?Python SubplotHost.twin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.axes_grid.parasite_axes.SubplotHost
的用法示例。
在下文中一共展示了SubplotHost.twin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_axis_two_scales
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import twin [as 别名]
def get_axis_two_scales(fig, scale_x, scale_y, \
ax2_xlabel = None, ax2_ylabel = None, \
subplot = 111,
sharex = None,
sharey = None):
kargs = {}
if (sharex != None):
kargs['sharex'] = sharex
if (sharey != None):
kargs['sharey'] = sharey
ax1 = SubplotHost(fig, subplot, **kargs)
ax1_to_2 = mtransforms.Affine2D().scale(1.0/scale_x, 1.0/scale_y)
ax2 = ax1.twin(ax1_to_2)
ax2.set_viewlim_mode("transform")
fig.add_subplot(ax1)
if (ax2_xlabel != None):
ax2.set_xlabel(ax2_xlabel)
if (ax2_ylabel != None):
ax2.set_ylabel(ax2_ylabel)
if (scale_x == 1.0):
ax2.get_xaxis().set_visible(False)
if (scale_y == 1.0):
ax2.get_yaxis().set_visible(False)
return ax1, ax2
示例2: SubplotHost
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import twin [as 别名]
obs = [["01_S1", 3.88, 0.14, 1970, 63],
["01_S4", 5.6, 0.82, 1622, 150],
["02_S1", 2.4, 0.54, 1570, 40],
["03_S1", 4.1, 0.62, 2380, 170]]
fig = plt.figure()
ax_kms = SubplotHost(fig, 1,1,1, aspect=1.)
# angular proper motion("/yr) to linear velocity(km/s) at distance=2.3kpc
pm_to_kms = 1./206265.*2300*3.085e18/3.15e7/1.e5
aux_trans = mtransforms.Affine2D().scale(pm_to_kms, 1.)
ax_pm = ax_kms.twin(aux_trans)
ax_pm.set_viewlim_mode("transform")
fig.add_subplot(ax_kms)
for n, ds, dse, w, we in obs:
time = ((2007+(10. + 4/30.)/12)-1988.5)
v = ds / time * pm_to_kms
ve = dse / time * pm_to_kms
ax_kms.errorbar([v], [w], xerr=[ve], yerr=[we], color="k")
ax_kms.axis["bottom"].set_label("Linear velocity at 2.3 kpc [km/s]")
ax_kms.axis["left"].set_label("FWHM [km/s]")
ax_pm.axis["top"].set_label("Proper Motion [$^{''}$/yr]")
ax_pm.axis["top"].label.set_visible(True)
示例3: temperature
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import twin [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()