In a plot of wind resistance versus coefficients of drag, I have the following line defining the legend for the black dashed curve:
ax.legend(perpendicular_plate,'Flat Perpendicular Plate')
However, the legend is displaying only one letter of the name. I have used a legend many times, but never the ax.legend
api...(top right corner)
What am I doing incorrectly to get this result?
答案 0 :(得分:2)
You need to give the label(s) as an iterable of strings (i.e. a list or a tuple), even if there's only one label.
So, this should work:
ax.legend([perpendicular_plate],['Flat Perpendicular Plate'])
So what's happening in your case is because strings are iterable in python, its iterating on your string, and taking just the first item of the string (F
), and using that.