我想设置我的颤动曲线轴的极限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)))]);
很高兴得到答案!提前致谢! :)
托拜厄斯
答案 0 :(得分:0)
我想我通过以下方式解决了这个问题:
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 ]))
然而,从结果来看,我认为没有区别,但逻辑运算符可以做到这一点。