更新时间:2023-02-26 22:32:40
这可能不是您想要的优雅解决方案,但是如果只想在大多数情况下获得结果,则可以剪切"绘图的大大小小的值数据分别发送到+∞
和-∞
. Matplotlib不会绘制这些.当然,您必须注意不要使分辨率太低或削波阈值太高.
This may not be the elegant solution you are looking for, but if just want results for most cases, you can "clip" large and small values of your plotted data to +∞
and -∞
respectively. Matplotlib does not plot these. Of course you have to be careful not to make your resolution too low or your clipping threshold too high.
utol = 100.
ltol = -100.
yy = 1/(xx-2)
yy[yy>utol] = np.inf
yy[yy<ltol] = -np.inf
ax.plot(xx, yy, zorder=100, linewidth=3, color='red')