在风阻与阻力系数的关系图中,我用下面的行定义了黑色虚线曲线的图例:
ax.legend(perpendicular_plate,'Flat Perpendicular Plate')
Run Code Online (Sandbox Code Playgroud)
但是,图例仅显示名称的一个字母。我用过很多次图例,但从来没有使用过ax.legendapi...(右上角)
我做错了什么才能得到这个结果?
您需要将标签作为可迭代的字符串(即列表或元组)提供,即使只有一个标签。
所以,这应该有效:
ax.legend([perpendicular_plate],['Flat Perpendicular Plate'])
Run Code Online (Sandbox Code Playgroud)
所以在你的情况下发生的事情是因为字符串在 python 中是可迭代的,它在你的字符串上迭代,只取字符串 ( F)的第一项,然后使用它。
| 归档时间: |
|
| 查看次数: |
5742 次 |
| 最近记录: |