qq_39790803 2021-06-06 11:13 采纳率: 33.3%
浏览 1301
已结题

请问大佬如何设置matplotlib子图table边框的粗细

默认的table边框较粗,想改一下,网上找了几个方法都没成功。

for cell_key, cell_i in table4.get_celld().items():
    cell_i.set_linewidth = line_width

cell6 = table6.get_celld()
for cell_y in range(stock_k):
    for cell_x in range(3):
        cell6[cell_x, cell_y].set_width = line_width

说明文档好像没提这块,或许是没找到。求教大佬们~~~~

  • 写回答

4条回答 默认 最新

  • 关注
    import numpy as np
    import matplotlib.pyplot as plt
    y = np.arange(1,10,1)
    x = np.arange(1,10,1)
    bwith = 1 #边框宽度设置为2
    ax = plt.gca()#获取边框
    ax.spines['top'].set_color('red')  # 设置上‘脊梁’为红色
    ax.spines['right'].set_color('none')  # 设置上‘脊梁’为无色
    ax.spines['bottom'].set_linewidth(bwith)
    ax.spines['left'].set_linewidth(bwith)
    ax.spines['top'].set_linewidth(bwith)
    ax.spines['right'].set_linewidth(bwith)
    plt.grid( color = 'black',linestyle='-.',linewidth = 1)
    plt.plot(x,y)
    

    代码如上,万望采纳。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 9月12日
  • 已采纳回答 9月4日