- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个 28 行 x 2 列的子图(实际上它可以改变)。第一列的所有行的 yaxis 比例应该是相同的(这也必须适用于第二列)......
所有的 x 轴都应该是相同的。
我想做的是在输出图中做一些东西,显示第一列和第二列的 yaxis 以及两列的 xaxis 是什么...我还想在顶部添加一个标签第一列和第二列(说明这些数据是什么)。
我还想更改绘图的纵横比,以便更清楚地看到它(可能增加 yaxis 纵横比大小并稍微减小 xaxis 大小)。
我想要的子图,没有调整大小,应该是这样的:
它可以是不同的东西。我真的不知道我的请求有什么可能。
我用来生成图形的代码(没有油漆标签):
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([])
非常感谢您的帮助。
我更改了代码,因为我意识到它们没有正确缩放。输出数字应该有点不同,但对于这个问题的目的来说并不重要。
最佳答案
我不完全确定你在问什么,但下面是我将如何沿着这些思路绘制一些东西......
图形的纵横比由 figsize
kwarg 控制到 plt.figure
(或 plt.subplots
,在这种情况下) .
剩下的你可以通过明智地应用annotate
来完成。
这是一个例子:
import matplotlib.pyplot as plt
import numpy as np
# Generate the data
data = (np.random.random((20, 2, 2, 1001)) - 0.5).cumsum(axis=-1)
# Set up the figure (the figsize is what's going to control your aspect ratio)
fig, axes = plt.subplots(nrows=20, ncols=2, sharex=True, figsize=(6, 10))
fig.subplots_adjust(wspace=0.1, hspace=0, bottom=0.05)
# Turn off tick labels everywhere
for ax in axes.flat:
for axis in [ax.xaxis, ax.yaxis]:
axis.set_ticklabels([])
# Plot the data
color = {(0,0):'red', (0,1):'green', (1,0):'blue', (1,1):'magenta'}
for (i,j), ax in np.ndenumerate(axes):
for k in range(2):
ax.plot(data[i,j,k,:], color=color[(j,k)])
# Add stacked titles (and text legends)
titles = [['TITLE:', 'Red: Data X', 'Green: Data Y'],
['TITLE:', 'Blue: Data W', 'Magenta: Data Z']]
for i, title in enumerate(titles):
for text, ypos in zip(title, [35, 20, 5]):
axes[0,i].annotate(text, xy=(0.05, 1.0), xytext=(0, ypos), va='bottom',
xycoords='axes fraction', textcoords='offset points')
# Add arrows on "super-Y" axes
xpos, length = -0.1, 5
axes[12,0].annotate('', xy=(xpos, 0), xytext=(xpos, length),
xycoords='axes fraction', textcoords='axes fraction',
arrowprops=dict(arrowstyle='<|-'))
axes[12,0].annotate('{0} subplots'.format(length), xy=(xpos, length/2.0),
xycoords='axes fraction', rotation=90, va='center', ha='right')
# Add arrows on "super-X" axes
ypos, length = -0.7, 1000
axes[-1,0].annotate('', xy=(0, ypos), xytext=(length, ypos),
xycoords=('data', 'axes fraction'), textcoords=('data', 'axes fraction'),
arrowprops=dict(arrowstyle='<|-'))
axes[-1,0].annotate('{0} data units'.format(length), xy=(length/2.0, ypos),
xytext=(0, 5), xycoords=('data', 'axes fraction'),
textcoords='offset points', ha='center', va='bottom')
plt.show()
关于python - 帮助使大的子图看起来更好更清晰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6942312/
据我所知,根本不为元素呈现 HTML,或添加 display:none,似乎具有完全相同的行为:两者都使元素消失并且不与 HTML 交互。 我正在尝试禁用和隐藏一个复选框。所以HTML的总量很小;我无
我刚刚读了Android Architecture Tutorial: Developing an App with a Background Service (using IPC) .基本上是 让服
我有两个查询具有相同的结果,现在我想知道哪个查询更优化? 在选择中: select t1.*, sum(t2.value) as total_votes from table1 t1 left joi
有人告诉我,对于 I/O 绑定(bind)的应用程序,非阻塞 I/O 会更好。对于 CPU 密集型应用程序,阻塞 I/O 会好得多。我找不到这种说法的原因。试过谷歌,但很少有文章只是触及这个话题而没有
我有一个算法可以在数字列表中寻找好的对。一个好的配对被认为是索引 i 小于 j 且 arr[i] 1: # Finding the mid of the array
我有一个算法可以在数字列表中寻找好的对。一个好的配对被认为是索引 i 小于 j 且 arr[i] 1: # Finding the mid of the array
我从 API 收到一个 json,我需要解析并修改一个属性值。问题是,我收到的 json 数据的嵌套结构不一致,我无法控制它。 这将禁止我指定在特定深度(如 parsedJson.children[0
我有 451 个城市的坐标。现在我想计算每个城市之间的距离,然后根据该距离对一些结果进行排序。现在我有两个选择: 我可以运行一个循环来计算每个可能的城市组合的距离并将它们存储到一个表中,这将产生大约
对于返回相同结果的不同查询,我有两个查询计划我想知道是否有人可以告诉我哪个“更好”,以及为什么。 SELECT * FROM bids order by (select ranking from us
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 7 年前。 Improve this qu
我有一个二维数组。我需要尽可能快地对其执行一些操作(函数每秒将被调用十几次,所以让它变得高效会很好)。 现在,假设我想获取元素 A[i][j],简单地使用 A[i][j] 在速度上有什么不同吗和 *(
在声明或使用字符串的代码中,我通常会看到开发人员这样声明它: string randomString = @"C:\Random\RandomFolder\ThisFile.xml"; 代替: str
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Why don't CSS resets use '*' to cover all elements? 我正
如果我有一个包含许多重复项的 python 列表,并且我想遍历每个项目,而不是重复项,最好使用一个集合(如 set(mylist),或者找到另一种方法来创建没有重复的列表?我想只是循环遍历列表并检查重
在阅读常量接口(interface)反模式时,我发现没有实例的最终常量类比常量接口(interface)更好。 请解释一下怎么做? public interface ConstIfc { publ
我正在查看我继承的一些旧代码,我真的不喜欢某些地方的风格。我真的不喜欢它的外观的一件事是: bool func() { bool ret = true; ret &= test1();
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 4 年前。 Improv
我经常发现自己试图使用 boost/QT 信号解耦对象。实现这一点的简单方法是针对我要通信的每个具体类型,创建一个新的信号和插槽签名并连接所有相关对象。这导致了访问者模式,理想情况下我想发出一个访问者
我正在 https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html 上阅读有关 lambda 的内容 在方法
public List getInts() { List xs = new ArrayList(); xs.add(1); // return Collections.unmo
我是一名优秀的程序员,十分优秀!