本文整理汇总了Python中mpl_toolkits.axes_grid.parasite_axes.SubplotHost.set_ylabel方法的典型用法代码示例。如果您正苦于以下问题:Python SubplotHost.set_ylabel方法的具体用法?Python SubplotHost.set_ylabel怎么用?Python SubplotHost.set_ylabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.axes_grid.parasite_axes.SubplotHost
的用法示例。
在下文中一共展示了SubplotHost.set_ylabel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MatplotlibTimelines
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_ylabel [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)
示例2: plotcomplexpolar
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_ylabel [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: SubplotHost
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_ylabel [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()
示例4: plotcomplex
# 需要导入模块: from mpl_toolkits.axes_grid.parasite_axes import SubplotHost [as 别名]
# 或者: from mpl_toolkits.axes_grid.parasite_axes.SubplotHost import set_ylabel [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