代码之家  ›  专栏  ›  技术社区  ›  Drudox lebowsky

如何在方框图上设置虚线轴

  •  0
  • Drudox lebowsky  · 技术社区  · 6 年前

    pyplot 设置绘图的虚线框(我的意思是绘图轮廓的轴)。

    1 回复  |  直到 6 年前
        1
  •  2
  •   ImportanceOfBeingErnest    6 年前

    轴“盒”由4个“刺”组成,可通过 ax.spines

    import matplotlib.pyplot as plt
    
    fig, axes = plt.subplots(2,2)
    
    linestyles = ["--","-.",":", (0,(5,2,1,4))]
    
    for ax, ls in zip(axes.flat, linestyles):
        for spine in ax.spines.values():
            spine.set_linestyle(ls)
            spine.set_linewidth(2)
        ax.set_title("linestyle: {}".format(ls))
    
    plt.tight_layout()
    plt.show()
    

    enter image description here