How to put legend outside of the graph at its bottom?
I would like to have legend located outside of the of the graph at the bottom. In the matplotlib legend guide there is an example how to locate it on the top:
# Place a legend above this subplot, expanding itself to # fully use the given bounding box. plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.)
Base on that example I write in Sage Note the following code:
p = line([(0, 0), (1, 1)], legend_label='test', axes_labels=('X LABEL', 'Y LABEL')) p.set_legend_options(bbox_to_anchor=(0., -.14, 1., .102), loc=3, mode="expand", borderaxespad=0.) p.show(frame=True, axes=False)
bbox_to_anchor parameter is (left, bottom, width, height) , the issue is that I have to manually set bottom (-.14 in the example) to compensate for the X label (it may be present, may be missing, may have a bigger font etc.)
Is there a way to automatically put legend on the bottom just below the x-axes label?