Remove the legend on a matplotlib figure

后端 未结 8 1149
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 19:01

To add a legend to a matplotlib plot, one simply runs legend().

How to remove a legend from a plot?

(The closest I came to this

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 19:16

    you have to add the following lines of code:

    ax = gca()
    ax.legend_ = None
    draw()
    

    gca() returns the current axes handle, and has that property legend_

提交回复
热议问题