import matplotlib.pyplot as plt
# create a 8" x 8" board
fig = plt.figure(figsize=[8,8])
fig.patch.set_facecolor((1,1,.8))
ax = fig.add_subplot(111)
# draw the grid
for x in range(19):
ax.plot([x, x], [0,18], 'k')
for y in range(19):
ax.plot([0, 18], [y,y], 'k')
# scale the axis area to fill the whole figure
ax.set_position([0,0,1,1])
# get rid of axes and everything (the figure background will show through)
ax.set_axis_off()
# scale the plot area conveniently (the board is in 0,0..18,18)
ax.set_xlim(-1,19)
ax.set_ylim(-1,19)
# draw Go stones at (10,10) and (13,16)
s1, = ax.plot(10,10,'o',markersize=30, markeredgecolor=(0,0,0), markerfacecolor='w', markeredgewidth=2)
s2, = ax.plot(13,16,'o',markersize=30, markeredgecolor=(.5,.5,.5), markerfacecolor='k', markeredgewidth=2)
当然可以。任何东西都可以画出来,只是需要多少代码。。。在
给出了:
如果你不喜欢背景,你甚至可以用
imshow
在那里放一些围棋板的漂亮照片或任何你需要的东西。在一件好事是,如果使用
^{pr2}$ax.plot
返回的对象,则可以删除它们并在不做大量工作的情况下重新填充板。在或者干脆
第一个显示正在进行的操作;line对象从line列表中删除,第二个对象输入速度更快,因为line对象知道它的父对象。在
不管怎样,它都不见了。(您可能需要调用
draw
来查看更改。)在python中有很多方法可以完成任务,
matplotlib
也不例外。根据tcaswell
的建议,这些线被网格代替,圆形标记用圆形补丁代替。而且,现在黑白宝石是从原型中创造出来的。在结果基本相同。在
相关问题 更多 >
编程相关推荐