由于某些原因,当我使用zorder
散点图时,点的边与轴重叠。我尝试了[这里](matplotlib axis tick labels covered by scatterplot (using spines))的一些解决方案,但它们对我不起作用。有没有办法阻止这种事情发生?你知道吗
我知道我也可以在我的边界添加一个ax.axvline()
,但这对于很多情节来说是一个恼人的解决方法。你知道吗
xval = np.array([0,0,0,3,3,3,0,2,3,0])
yval = np.array([0,2,3,5,1,0,1,0,4,5])
zval = yval**2-4
fig = plt.figure(figsize=(6,6))
ax = plt.subplot(111)
ax.scatter(xval,yval,cmap=plt.cm.rainbow,c=zval,s=550,zorder=20)
ax.set_ylim(0,5)
ax.set_xlim(0,3)
#These don't work
ax.tick_params(labelcolor='k', zorder=100)
ax.tick_params(direction='out', length=4, color='k', zorder=100)
#This will work but I don't want to have to do this for the plot edges every time
ax.axvline(0,c='k',zorder=100)
plt.show()
这对我有用
你的圆尺寸足够大,它们超出了轴的范围。所以我们只需更改
ylim
和xlim
已更改
至
而且,zorder在将点推到边缘方面也不起作用。你知道吗
对我来说,您链接到的解决方案是有效的;也就是说,将散点图的z顺序设置为负数。例如
]1
可以使用以下代码修复重叠,代码中的
zorder
有一个较大的数字。这将在x轴和y轴上工作。你知道吗相关问题 更多 >
编程相关推荐