Viewing and working with plots

The Plots tab offers a convenient way to browse through and manage any and all plots that are generated by our Python programs. Now, let's see it in action by executing our current program to generate the plots.

Note that, in order to take full advantage of the various features we are discussing, we will run this program in the console. To do this, right-click on the background of your editor and choose the Run File in Console option. As the program executes, you will see that the histograms that Matplotlib generates are included in the SciView panel, specifically in its Plots tab (as highlighted here):

Viewing plots in PyCharm's SciView panel

The first thing you will notice here is that each time a plot was generated, its output was appended and shown to the SciView panel, and the program continued its execution. In the end, we were left with a whole array of plots, which you can navigate through by clicking on the different icons on the right-hand side of the panel.

The same program, when running via a traditional Python interpreter, would pause to display each of the generated plots and only move on after any interaction from the user (typically, when the Q key is pressed). This is because plt.show(), by default, blocks the execution of any program that contains the method call.

Here, our program ran in one go and all the generated plots were saved to the SciView panel. This feature is more useful than some might think. For example, when we want to generate a large number of plots that will be viewed and compared with one another, the way PyCharm handles the execution is optimal for that purpose. When using a regular Python interpreter, we would need to save the plots to files manually to achieve the same effect.

Getting back to the SciView panel, as you click on and display a given plot, you also have the option to zoom in and out using the toolbar at the top of the panel, remove the plot from view using the X button to the right of its icon, or save the plot to an image file, or remove all the plots from view by right-clicking on the plot icon, as follows:

More options for working with plots in PyCharm

Working with plots in PyCharm via the SciView panel is arguably better than interacting with a bare-bones Python interpreter, for many reasons that we have already discussed. However, this is not the only use for the SciView panel. We have mentioned that all the plots that are generated by our Python program are included in the Plots tab of the SciView panel. The other tab, as you might have noticed, is the Data tab, which we will discuss in the next subsection.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.166.98