帮助使大的子图看起来更漂亮、更清晰
我有一个 28 行 x 2 列的子图(实际上它可以改变)。第一列所有行的 y 轴刻度应该相同(也必须适用于第二列)......
所有 x 轴都应该相同。
我想要做的是在输出图中制作一些内容,显示第一列和第二列的 y 轴是什么以及两列的 x 轴是什么...我还想在第一列的顶部添加一个标签,第二列(说明这些数据是什么)。
我还想更改绘图的方面,以便可以更清楚地看到它(可能增加 y 轴方面的大小并稍微减少 x 轴的大小)。
我想要的子图,无需重新调整大小,应该是这样的:
它可以是不同的东西。我真的不知道我的要求可以实现什么。
我用来生成图形的代码(没有油漆制作的标签):
def pltconc(conc,self):
t=self.t
idx1=0
conc=conc*1000000
c=len(find( self.ml[:,3]==1 ))
from scipy.stats import scoreatpercentile #To adjust the scales
ymin1 = max([median(scoreatpercentile(conc[:,i,:],0.05)) for i in range(28)])
ymax1 = max([median(scoreatpercentile(conc[:,i,:],99.95)) for i in range(28)])
for idx1 in range(c):
a=subplot(c,2,2*idx1+1, adjustable='box-forced')
plt.plot(t,conc[:,idx1,0],color='r')
plt.plot(t,conc[:,idx1,1],color='b')
plt.axis('tight')
xlim(0,max(self.t))
ylim(ymin1,ymax1)
frame1 = plt.gca()
a.set_yticklabels([])
a.set_xticklabels([])
ax=subplot(c,2,2*idx1+2, adjustable='box-forced')
CBV = (conc[:,idx1,2]*100)/(90+conc[:,idx1,2])
StO2 = (conc[:,idx1,0]*100)/(90+conc[:,idx1,2])
ymin2 = max(median(scoreatpercentile(CBV,0.05)),median(scoreatpercentile(StO2,0.05)))
ymax2 = max(median(scoreatpercentile(StO2,99.95)),median(scoreatpercentile(CBV,99.95)))
plt.plot(t,CBV, color='m')
plt.plot(t,StO2, color = 'b')
plt.axis('tight')
xlim(0,max(self.t))
ylim(ymin2,ymax2)
frame1 = plt.gca()
ax.set_yticklabels([])
ax.set_xticklabels([])
非常感谢您的帮助。
因为我意识到它们没有正确缩放,所以我更改了代码。输出数字应该有点不同,但这对于这个问题的目的来说并不重要。
I have a subplot of 28 lines x 2 columns(it can change, actually). The yaxis scale of all the lines of the 1st column is supposed to be the same (that must work for that 2nd column as well)....
All the xaxis are supposed to be the same.
What I want to do is to make something inside the output figure that shows what is the yaxis for the 1st and 2nd columns and what is the xaxis for both columns... I also want to get a label to up top at the 1st and 2nd column (saying what are those data).
I also want to change the aspect of the plots so that it can be seen more clearly (probably increasing the yaxis aspect size and drecreasing the xaxis size a little).
The subplot I want, without the re-sizing, should be something like this:
It can be something different. I really don't know whats possible to make out of my request.
The code i usd to generate the figure (without the paint-made labels):
def pltconc(conc,self):
t=self.t
idx1=0
conc=conc*1000000
c=len(find( self.ml[:,3]==1 ))
from scipy.stats import scoreatpercentile #To adjust the scales
ymin1 = max([median(scoreatpercentile(conc[:,i,:],0.05)) for i in range(28)])
ymax1 = max([median(scoreatpercentile(conc[:,i,:],99.95)) for i in range(28)])
for idx1 in range(c):
a=subplot(c,2,2*idx1+1, adjustable='box-forced')
plt.plot(t,conc[:,idx1,0],color='r')
plt.plot(t,conc[:,idx1,1],color='b')
plt.axis('tight')
xlim(0,max(self.t))
ylim(ymin1,ymax1)
frame1 = plt.gca()
a.set_yticklabels([])
a.set_xticklabels([])
ax=subplot(c,2,2*idx1+2, adjustable='box-forced')
CBV = (conc[:,idx1,2]*100)/(90+conc[:,idx1,2])
StO2 = (conc[:,idx1,0]*100)/(90+conc[:,idx1,2])
ymin2 = max(median(scoreatpercentile(CBV,0.05)),median(scoreatpercentile(StO2,0.05)))
ymax2 = max(median(scoreatpercentile(StO2,99.95)),median(scoreatpercentile(CBV,99.95)))
plt.plot(t,CBV, color='m')
plt.plot(t,StO2, color = 'b')
plt.axis('tight')
xlim(0,max(self.t))
ylim(ymin2,ymax2)
frame1 = plt.gca()
ax.set_yticklabels([])
ax.set_xticklabels([])
Thanks alot for the help.
I changed the code since I've realized they weren't correctly scaled. The output figure should be a little bit differente, but it doesn't really matters for this questions purpose.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全确定你在问什么,但这是我如何沿着这些线绘制一些东西......
你的图形的长宽比由
figsize
kwarg 到plt.figure
(或在本例中为plt.subplots
)。剩下的事情你可以通过明智地应用
annotate
来完成。这是一个示例:
I'm not entirely sure what you're asking, but here's how I'd go about plotting something along those lines...
The aspect ratio for your figure is controlled by the
figsize
kwarg toplt.figure
(orplt.subplots
, in this case).The rest you can do with judicious application of
annotate
.Here's an example: