我的目标是在我使用pcolor创建的现有网格标记上添加一组粗网格标记(请参见下面的代码)。每N条(例如5条)较细的网格线将有一条粗的网格线。我要添加的网格线可能类似于主要刻度线,而现有网格线可能类似于次要刻度线。
我的代码:
Z = np.random.rand(25, 25)
fig=plt.figure(figsize=(18, 16), dpi= 80, facecolor='w', edgecolor='k')
gs = gridspec.GridSpec(2, 3, width_ratios=[1,1,0.1])
ax1 = plt.subplot(gs[0,1])
plt1 = ax1.pcolor(Z, cmap=plt.cm.Blues, edgecolors='k', linewidths=1)
cbax = plt.subplot(gs[0,2])
cb = Colorbar(ax=cbax, mappable = plt1)
输出图像:random data with grid lines
带有红线的医生图像显示了我想要的主要网格:same data with doctored red grid lines
任何人都有很好的解决方案或为此解决吗?
Z = np.random.rand(25, 25)
fig=plt.figure(figsize=(18, 16), dpi= 80, facecolor='w', edgecolor='k')
gs = gridspec.GridSpec(2, 3, width_ratios=[1,1,0.1])
ax1 = plt.subplot(gs[0,1])
plt1 = ax1.pcolor(Z, cmap=plt.cm.Blues, edgecolors='k', linewidths=1)
ax1.xaxis.set_major_locator(MultipleLocator(5))
ax1.yaxis.set_major_locator(MultipleLocator(5))
ax1.grid(b=True, which='major', color='r', linestyle='-')
cbax = plt.subplot(gs[0,2])
cb = Colorbar(ax=cbax, mappable = plt1)