Closed
Description
Bug report
Bug summary
Automatic placing of legend seems to be not working with histograms of type step*
. If I am correct, this is a new entry in the long list of current issues with legend ^^.
Code for reproduction
import matplotlib.pyplot as plt
hist_types = ('bar', 'barstacked', 'step', 'stepfilled')
fig, axs = plt.subplots(nrows=len(hist_types), num="test")
for ax, ht in zip(axs.flat, hist_types):
ax.set_title(ht)
ax.hist([0] + 5*[9], bins=range(10), label=f"This is a label", histtype=ht)
ax.legend(loc="best")
fig.tight_layout()
#fig.savefig(fig.get_label() + ".png")
Actual outcome
Matplotlib 2.1
Expected outcome
The same auto-position of the legend on each subplot, i.e. upper left, whatever is the histogram style.
Matplotlib version
- Operating system: GNU/Linux (Fedora 26)
- Matplotlib version: 2.1 from conda (also test “successfully” with master)
- Matplotlib backend (
print(matplotlib.get_backend())
): Qt5Agg - Python version: 3.6.3 from conda
- Jupyter version (if applicable): X
- Other libraries: X
FWIW, I tried the above snippet on Matplotlib 1.5.0 and the result is similar.
Edit: tweaked a bit the snippet to be Matplotlib v1.5.x-compliant.