I'm trying to put a legend to my plot but it is aligned from top to bottom, how can I make the text in legend horizontal? Thanks in advance.
fig, ax = plt.subplots()
sp=ax.contourf(x1line, x2line, pgrid)
plt.colorbar(sp)
ax.legend('label1')
CodePudding user response:
ax.legend
expects a list of strings as its argument. Try this:
ax.legend(['label1'])
Since you passed a string (vs. a list) the string is treated as an iterable and each character becomes its own row in the legend.