【发布时间】:2020-11-30 19:18:54
【问题描述】:
我想在背景中创建一些带有网格的 xkcd 图。像这样example,但是当plt.xkcd() 时,网格不会出现在图中。
from matplotlib import pyplot as plt
import numpy as np
plt.xkcd()
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
plt.xticks([])
plt.yticks([])
ax.set_ylim([-30, 10])
plt.grid()
data = np.ones(100)
data[70:] -= np.arange(30)
plt.annotate(
'THE DAY I REALIZED\nI COULD COOK BACON\nWHENEVER I WANTED',
xy=(70, 1), arrowprops=dict(arrowstyle='->'), xytext=(15, -10))
plt.plot(data)
plt.xlabel('time')
plt.ylabel('my overall health')
plt.show()
在使用 mplot3d 完成绘图的情况下,网格正在“工作”,如example 所示。虽然,网格似乎是完美。如何创建网格?
【问题讨论】:
标签: python matplotlib