Setting `axes.linewidth` without changing the `rcParams` global dict

后端 未结 4 2029
有刺的猬
有刺的猬 2020-12-05 07:02

So, it seems one cannot do the following (it raises an error, since axes does not have a set_linewidth method):

axes_style = {\'lin         


        
4条回答
  •  独厮守ぢ
    2020-12-05 07:20

    If you're recursively creating (non-rectangular) axes using pyplot, you can change the linewidth parameter for each ax.

    For instance:

    import matplotlib.pyplot as plt
    
    plt.figure(figsize = figsize)
    fig, ax = plt.subplots(figsize = figsize)
    for shape in sf.shapeRecords():
        x = [i[0] for i in shape.shape.points[:]]
        y = [i[1] for i in shape.shape.points[:]]
        ax.plot(x, y, 'k', linewidth=5)
    

    For documentation, see MPL.axes documentation (Scroll down until "Other Parameters" -> **kwargs)

    N.B. "If you make multiple lines with one plot command, the kwargs apply to all those lines."

    Maybe this solution is related to a different question asked elsewhere, but I found this page looking for a solution to my own problem, so maybe it can help others looking for the same thing.

提交回复
热议问题