[英]Missing X and Y axis when plotting using python
I having some issue replicating the example code for scatter plots in python. 我在复制python中的散点图示例代码时遇到一些问题。 The code I am trying to replicate:
我正在尝试复制的代码:
x = np.random.rand(10)
y = np.random.rand(10)
z = np.sqrt(x**2 + y**2)
plt.subplot(321)
plt.scatter(x, y, s=80, c=z, marker=">")
plt.subplot(322)
plt.scatter(x, y, s=80, c=z, marker=(5, 0))
verts = list(zip([-1., 1., 1., -1.], [-1., -1., 1., -1.]))
plt.subplot(323)
plt.scatter(x, y, s=80, c=z, marker=(verts, 0))
# equivalent:
#plt.scatter(x,y,s=80, c=z, marker=None, verts=verts)
plt.subplot(324)
plt.scatter(x, y, s=80, c=z, marker=(5, 1))
plt.subplot(325)
plt.scatter(x, y, s=80, c=z, marker='+')
plt.subplot(326)
plt.scatter(x, y, s=80, c=z, marker=(5, 2))
plt.show()
But this is what I am getting: 但这就是我得到的:
I can get the background to white by: 我可以通过以下方式将背景设置为白色:
ax = plt.gca()
ax.set_axis_bgcolor('white')
But I can not get to display X and Y axis. 但是我无法显示X和Y轴。 I have tried many solutions from other stackoverflow posts but none of them seems to be working.
我已经尝试了其他stackoverflow帖子中的许多解决方案,但似乎都没有用。
Could someone please help me solve this issue? 有人可以帮我解决这个问题吗?
Thanks to @HYRY's solution. 感谢@HYRY的解决方案。
Some more references about style sheets in matplotlib for beginners like me: 对于像我这样的初学者,更多有关matplotlib中样式表的参考:
Customizing plots with style sheets 使用样式表自定义图
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.