Python:如何在箭袋图轴的范围内添加第二个 "non-Nan" 条件?
Python: How can i add a second "non-Nan"-condition to the limits of my quiver plot axis?
我想设置箭袋图轴的限制 s.t。外部使用的网格中的 NaN 不会导致我的 ax 限制在没有任何数据点的情况下不必要地过长。
我自己得到的是:
import numpy as np
pylab.xlim(np.min(Km[np.isnan(C_diff) < 0.5 ]), np.max(Km[np.isnan(C_diff) < 0.5 ]))
#two conditions: "np.min(Cm[np.isnan(K_diff) < 0.5" on min, max (Km) are missing
pylab.ylim(np.min(Cm[np.isnan(K_diff) < 0.5 ]), np.max(Cm[np.isnan(K_diff) < 0.5 ]))
#two conditions: "np.min(Km[np.isnan(K_diff) < 0.5" on min, max (Cm) are missing
为了进一步说明,我想要用 matlab 语言:
xlim([min(min(Km(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5))),
max(max(Km(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5)))]);
ylim([min(min(Cm(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5))),
max(max(Cm(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5)))]);
很高兴得到答案!提前致谢! :)
托比亚斯
我想我通过以下方式修复了它:
pylab.xlim(np.min(Km[np.isnan(C_diff)^np.isnan(K_diff).all() < 0.5 ]),
np.max(Km[np.isnan(C_diff)^np.isnan(K_diff).all() < 0.5 ]))
pylab.ylim(np.min(Cm[np.isnan(K_diff)^np.isnan(C_diff).all() < 0.5 ]),
np.max(Cm[np.isnan(K_diff)^np.isnan(C_diff).all() < 0.5 ]))
然而,从结果来看我看不出有什么不同,但这是可以通过逻辑运算符实现的。
我想设置箭袋图轴的限制 s.t。外部使用的网格中的 NaN 不会导致我的 ax 限制在没有任何数据点的情况下不必要地过长。
我自己得到的是:
import numpy as np
pylab.xlim(np.min(Km[np.isnan(C_diff) < 0.5 ]), np.max(Km[np.isnan(C_diff) < 0.5 ]))
#two conditions: "np.min(Cm[np.isnan(K_diff) < 0.5" on min, max (Km) are missing
pylab.ylim(np.min(Cm[np.isnan(K_diff) < 0.5 ]), np.max(Cm[np.isnan(K_diff) < 0.5 ]))
#two conditions: "np.min(Km[np.isnan(K_diff) < 0.5" on min, max (Cm) are missing
为了进一步说明,我想要用 matlab 语言:
xlim([min(min(Km(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5))),
max(max(Km(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5)))]);
ylim([min(min(Cm(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5))),
max(max(Cm(real(~(isnan(K_diff))).*real(~(isnan(C_diff))) > 0.5)))]);
很高兴得到答案!提前致谢! :)
托比亚斯
我想我通过以下方式修复了它:
pylab.xlim(np.min(Km[np.isnan(C_diff)^np.isnan(K_diff).all() < 0.5 ]),
np.max(Km[np.isnan(C_diff)^np.isnan(K_diff).all() < 0.5 ]))
pylab.ylim(np.min(Cm[np.isnan(K_diff)^np.isnan(C_diff).all() < 0.5 ]),
np.max(Cm[np.isnan(K_diff)^np.isnan(C_diff).all() < 0.5 ]))
然而,从结果来看我看不出有什么不同,但这是可以通过逻辑运算符实现的。