如何让我的matplotlib图超出坐标轴?
我必须将图像绘图脚本从matlab转换为matplotlib/pylab,并且我试图实现与以下matlab图像相同的效果:
I have to translate an image plotting script from matlab to matplotlib/pylab, and I'm trying to achieve the same effect as the matlab image below:
如您所见,图的z顺序似乎高于网格的z顺序,因此标记不会被轴隐藏.但是,我想不出一种方法来对我的matplotlib映像进行同样的操作:
As you can see, the z order of the plots seem to be higher than the z order of the grid, so the markers are not hidden by the axes. However, I can't figure out a way to do the same with my matplotlib image:
我想知道是否可以在不增加y轴限制的情况下获得相同的显示.
I'm wondering if it is possible to get the same display without having to increase the limits of the y axis.
要使标记显示在轴之外,可以关闭剪切.可以使用plot
命令clip_on=False
中的关键字参数来完成.
To get the marker to show beyond the axes you can turn the clipping off. This can be done using the keyword argument in the plot
command clip_on=False
.
例如:
import matplotlib.pyplot as plt
plt.plot(range(5), range(5), 'ro', markersize=20, clip_on=False, zorder=100)
plt.show()