【发布时间】:2023-04-02 02:30:01
【问题描述】:
我有一个matplotlib gridspec 的情节如下:
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
fig2 = plt.figure(figsize=[8,8])
spec2 = gridspec.GridSpec(ncols=2, nrows=2, figure=fig2)
f2_ax1 = fig2.add_subplot(spec2[0, 0])
f2_ax2 = fig2.add_subplot(spec2[0, 1])
f2_ax3 = fig2.add_subplot(spec2[1, 0])
f2_ax4 = fig2.add_subplot(spec2[1, 1])
我想为上面的图添加网格线。我无法使用 hlines 做到这一点,因为 gridpec 属性没有对象 hlines。
是否可以在 matplotlib 中为 gridspec 对象添加 gridlines,如下所示:
【问题讨论】:
-
discourse.matplotlib.org/t/… 这可能会有所帮助
标签: python matplotlib data-visualization