本文整理汇总了Python中mpl_toolkits.axes_grid.parasite_axes.SubplotHost.plot方法的典型用法代码示例。如果您正苦于以下问题:Python SubplotHost.plot方法的具体用法?Python SubplotHost.plot怎么用?Python SubplotHost.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.axes_grid.parasite_axes.SubplotHost
的用法示例。
在下文中一共展示了SubplotHost.plot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SubplotHost
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import plot [as 别名]
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
import matplotlib.pyplot as plt
fig = plt.figure(1)
host = SubplotHost(fig, 111)
fig.add_subplot(host)
par = host.twinx()
host.set_xlabel("Distance")
host.set_ylabel("Density")
par.set_ylabel("Temperature")
p1, = host.plot([0, 1, 2], [0, 1, 2], label="Density")
p2, = par.plot([0, 1, 2], [0, 3, 2], label="Temperature")
host.axis["left"].label.set_color(p1.get_color())
par.axis["right"].label.set_color(p2.get_color())
host.legend()
plt.show()
示例2: plotcomplexpolar
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import plot [as 别名]
def plotcomplexpolar(metaAry, size = (10, 7.5), dpi = 75, grid = True, legend = 0, fontsize = 15):
"""
metaArray function to do a simple 1D plot of complex array as magnitude and phase angle.
legend:
'best' 0
'upper right' 1
'upper left' 2
'lower left' 3
'lower right' 4
'right' 5
'center left' 6
'center right' 7
'lower center' 8
'upper center' 9
'center' 10
"""
if legend is None:
legend = 0
axis = metaAry['range']
mag = abs(metaAry.data)
pha = angle(metaAry.data, deg=True)
# Load the plotting ranges and units
x0 = axis['begin'][0]
x1 = axis['end'][0]
my0 = min(mag)
my1 = max(mag)
py0 = min(pha)
py1 = max(pha)
xunit = axis['unit'][0]
myunit = metaAry['unit']
pyunit = 'Degree'
# Leave 10% margin in the y axis
mmean = average((my0, my1))
mreach = abs(my0-my1) / 2 / 0.9
my0 = sign(my0-mmean) * mreach + mmean
my1 = sign(my1-mmean) * mreach + mmean
pmean = average((py0, py1))
preach = abs(py0-py1) / 2 / 0.9
py0 = sign(py0-pmean) * preach + pmean
py1 = sign(py1-pmean) * preach + pmean
# Apply unit prefix if unit is defined
xunit, x0, x1, xscale = prettyunit(xunit, x0, x1)
myunit, my0, my1, myscale = prettyunit(myunit, my0, my1)
pyunit, py0, py1, pyscale = prettyunit(pyunit, py0, py1)
if myscale != 1:
mag = mag * myscale
if pyscale != 1:
pha = pha.copy() * pyscale
xlabl = lbl_repr(axis['label'][0], xunit)
mylabl = lbl_repr(metaAry['label'], myunit, "Magnitude")
pylabl = lbl_repr(metaAry['label'], pyunit, "Phase angle")
title = metaAry['name']
fig = figure(figsize=size, dpi = dpi)
host = SubplotHost(fig, 111)
fig.add_subplot(host)
par = host.twinx()
if axis['log'][0] is False:
x = linspace(x0, x1, len(metaAry))
else:
raise NotImplemented, "Log axis is not yet implemented."
host.plot(x, mag, 'b-', label=lbl_repr(axis['label'][0], '', "Magnitude"))
par.plot(x, pha, 'r--', label=lbl_repr(axis['label'][0], '', "Phase"))
host.grid(grid)
host.set_xlabel(xlabl, fontsize=fontsize)
host.set_ylabel(mylabl, fontsize=fontsize)
par.set_ylabel(pylabl, fontsize=fontsize)
host.set_xlim([x0, x1])
host.set_ylim([my0, my1])
par.set_ylim([py0, py1])
if fontsize is not None:
host.set_title(title, fontsize=int(fontsize*1.3))
else:
host.set_title(title)
if legend >= 0:
host.legend(loc=legend)
return fig, host, par
示例3: temperature
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import plot [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()
示例4: plotcomplex
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import plot [as 别名]
def plotcomplex(metaAry, size = (10, 7.5), dpi = 75, grid = True, legend = 0, fontsize = 15):
"""
metaArray function to do a simple 1D plot of complex array as real and imaginary parts.
legend:
'best' 0
'upper right' 1
'upper left' 2
'lower left' 3
'lower right' 4
'right' 5
'center left' 6
'center right' 7
'lower center' 8
'upper center' 9
'center' 10
"""
if legend is None:
legend = 0
axis = metaAry['range']
rdata = metaAry.data.real
idata = metaAry.data.imag
# Load the plotting ranges and units
x0 = axis['begin'][0]
x1 = axis['end'][0]
ry0 = min(rdata)
ry1 = max(rdata)
iy0 = min(idata)
iy1 = max(idata)
xunit = axis['unit'][0]
ryunit = metaAry['unit']
iyunit = metaAry['unit']
# Leave 10% margin in the y axis
rmean = average((ry0, ry1))
rreach = abs(ry0-ry1) / 2 / 0.9
ry0 = sign(ry0-rmean) * rreach + rmean
ry1 = sign(ry1-rmean) * rreach + rmean
imean = average((iy0, iy1))
ireach = abs(iy0-iy1) / 2 / 0.9
iy0 = sign(iy0-imean) * ireach + imean
iy1 = sign(iy1-imean) * ireach + imean
# Apply unit prefix if unit is defined
xunit, x0, x1, xscale = prettyunit(xunit, x0, x1)
ryunit, ry0, ry1, ryscale = prettyunit(ryunit, ry0, ry1)
iyunit, iy0, iy1, iyscale = prettyunit(iyunit, iy0, iy1)
if ryscale != 1:
rdata = rdata.copy() * ryscale
if iyscale != 1:
idata = idata.copy() * iyscale
xlabl = lbl_repr(axis['label'][0], xunit)
rylabl = lbl_repr(metaAry['label'], ryunit, "Real part")
iylabl = lbl_repr(metaAry['label'], iyunit, "Imaginary part")
title = metaAry['name']
fig = figure(figsize=size, dpi = dpi)
host = SubplotHost(fig, 111)
fig.add_subplot(host)
par = host.twinx()
if axis['log'][0] is False:
x = linspace(x0, x1, len(metaAry))
else:
raise NotImplemented, "Log axis is not yet implemented."
host.plot(x, rdata, 'b-', label=lbl_repr(axis['label'][0], '', "Real"))
par.plot(x, idata, 'r--', label=lbl_repr(axis['label'][0], '', "Imaginary"))
host.grid(grid)
host.set_xlabel(xlabl, fontsize=fontsize)
host.set_ylabel(rylabl, fontsize=fontsize)
par.set_ylabel(iylabl, fontsize=fontsize)
host.set_xlim([x0, x1])
host.set_ylim([ry0, ry1])
par.set_ylim([iy0, iy1])
if fontsize is not None:
host.set_title(title, fontsize=int(fontsize*1.3))
else:
host.set_title(title)
if legend >= 0:
host.legend(loc=legend)
return fig, host, par