【发布时间】:2015-07-08 00:51:45
【问题描述】:
在 python 中是否有一种简单的方法使用 pyplot (matplotlib) 创建一个矩形网格(像这样,但可能是网格化的),如下所示:
我对python很陌生,可能有一个简单的解决方案,但我一直找不到。
提前致谢。
【问题讨论】:
标签: python python-2.7 matplotlib
在 python 中是否有一种简单的方法使用 pyplot (matplotlib) 创建一个矩形网格(像这样,但可能是网格化的),如下所示:
我对python很陌生,可能有一个简单的解决方案,但我一直找不到。
提前致谢。
【问题讨论】:
标签: python python-2.7 matplotlib
目前尚不清楚您要了解哪些细节,但这是一个开始......
import matplotlib.pyplot as plt
ax = plt.subplot(1, 1, 1)
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.set_xticks(range(-5, 6))
ax.set_yticks(range(-5, 6))
ax.set_xlim((-5.5, 5.5))
ax.set_ylim((-5.5, 5.5))
ax.grid()
plt.show()
【讨论】: