Need to add space between SubPlots for X axis label, maybe remove labelling of axis notches

前端 未结 2 1873
臣服心动
臣服心动 2020-12-24 06:34

Looking to add in vertical space between plotted graphs to allow a X-Axis label to show:

Each graph needs to have space to show the day, currently the last 2 graphs

相关标签:
2条回答
  • To change the spacing around a certain subplot, instead of all of them, you can adjust the position of the axes of that subplot using:

    bbox=plt.gca().get_position()
    offset=-.03
    plt.gca().set_position([bbox.x0, bbox.y0 + offset, bbox.x1-bbox.x0, bbox.y1 - bbox.y0])
    

    If offset < 0, the subplot is moved down. If offset > 0, the subplot is moved up.

    Note that the subplot will disappear if offset is so big that the new position of the subplot overlaps with another subplot.

    0 讨论(0)
  • 2020-12-24 07:09

    Use subplots_adjust. In your case this looks good:

    fig.subplots_adjust(hspace=.5)
    

    to remove the tick labels do this:

    ax1.set_xticklabels([])
    

    Similar for the yticklabels. However, you cannot share the x-axis with the plots that do have tick labels.

    enter image description here

    0 讨论(0)
提交回复
热议问题