Python Matplotlib figure title overlaps axes label when using twiny

前端 未结 6 1975
滥情空心
滥情空心 2020-11-27 11:42

I am trying to plot two separate quantities on the same graph using twiny as follows:

fig = figure()
ax = fig.add_subplot(111)
ax.plot(T, r, \'b-\', T, R, \'         


        
6条回答
  •  旧巷少年郎
    2020-11-27 12:04

    I was having an issue with the x-label overlapping a subplot title; this worked for me:

    import matplotlib.pyplot as plt
    fig, ax = plt.subplots(2, 1)
    ax[0].scatter(...)
    ax[1].scatter(...)
    plt.tight_layout()
    .
    .
    .
    plt.show()
    

    before

    after

    reference:

    • https://matplotlib.org/users/tight_layout_guide.html

提交回复
热议问题