Horizontally align bar plot legends in python
问题 I have made a multi axis graph using the following code and I am unable to arrange the legend as I want. The code of my graph is as follows: import matplotlib.pyplot as plt import numpy as np x = np.arange(4) y = [5, 7, 4, 9] z = [9, 3, 5, 6] r = [30, 40, 45, 37] fig,ax = plt.subplots() abc = ax.bar(x,y,0.25 ) cde = ax.bar(x+0.25,z,0.25) ax.legend((abc[0], cde[0]), ('y', 'z'),bbox_to_anchor=(0., 1.02, 1, .102) , borderaxespad=0.) ax.set_xticks(x + 0.25 / 2) ax.set_xticklabels(('A', 'B', 'C',