How to put the legend outside the plot in Matplotlib

Placing the legend (bbox_to_anchor) A legend is positioned inside the bounding box of the axes using the loc argument to plt.legend. E.g. loc=”upper right” places the legend in the upper right corner of the bounding box, which by default extents from (0,0) to (1,1) in axes coordinates (or in bounding box notation (x0,y0, width, height)=(0,0,1,1)). … Read more

In Matplotlib, what axis attribute specifies the spacing between ticks? [duplicate]

A more recent answer to the related question illustrates using the matplotlib.ticker.MultipleLocator object. The axis ticks are this type of matplotlib object. Here is an example of it’s use. ax.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(5)) will place ticks 5 units apart on the x-axis, and ax.xaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(1)) will place minor ticks 1 unit apart on the x-axis. Here is an example … Read more

tech