I use an external module that automatically adds a legend to the plot. I would like to know if there is a way to disable the legend, something like ax.set_legend (False).
I could fix this by hacking the module, but I would not do it.
Example:
f = plt.figure() ax = f.add_subplot(111) externalfunction(ax) # in the function ax.legend() has been called # would like to turn off the legend here plt.show()
Update:
I raised a github question for this https://github.com/matplotlib/matplotlib/issues/2792
You need to change the visibility of your legend, try the following: ax.legend().set_visible(False)
ax.legend().set_visible(False)
You can also do this by setting the legend_axis attribute to None. Pay attention to the underline. For instance.
legend_
None
x, y = np.random.randn(2, 30) ax = plt.gca() ax.plot(x, y, label="data") ax.legend() ax.legend_ = None
, matplotlib , / .