3 ms·
> The syntax of python is also a bit verbose. Like, why do we need plt.show(), when I plot a figure obviously I want to plot it! That is kind of annoying. Fort
by Keysh 2y ago
> The syntax of python is also a bit verbose. Like, why do we need plt.show(), when I plot a figure obviously I want to plot it!
That is kind of annoying. Fortunately, it's easy to turn that off by activating "interactive mode", in which figures automatically appear when you use a plotting command. You can do this via "plt.ion()", or have it set automatically with
interactive : True
in your .matplotlibrc file.
- setopt 2y agoJust keep in mind that when you do this, most plots will by default reuse the existing frame without clearing it. So you need to manually call plt.figure() more often (which in my opinion is more logical than plt.show). There’s also a change in semantics regarding whether the script “hangs” until the user closes the plot window, if I recall correctly.
- Keysh 2y agoOr you can call plt.clf() to clear the frame.