- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
When is plt.Show() required to show a plot and when is it not?
plt.Show() would help whenever there is no interactive plot.
fig.Show() would help to display all the figures if it is interactive.
Let's take an example to observe the difference between plt.Show() and fig.Show().
Steps
Open iPython shell.
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure.
Plot a line using plot() method.
Display the figure using Show() method.
To display the figure, use Show() method with block=False.
Example
import numpy as np from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create a new figure fig = plt.figure() # Plot a line plt.plot(np.linspace(-5, 5, 100)) fig.show() plt.show(block=False)
Output
It will produce the following output −
You would get this output only in interactive mode. plt.Show() with block=True would show the output when there is no interactive plot.
- Related Articles
- When is it required to find the LCM of numbers?
- How can I show a hidden div when a select option is selected in JavaScript?
- How faster is the time when we think of something and Google will show results?
- When to use inline function and when not to use it in C/C++?
- Is `definer` required when creating a MySQL stored procedure?
- Why does HCL gas show its acidic nature only when it dissolves in water?
- When to use new operator in C++ and when it should not be used?
- Show tick labels when sharing an axis in Matplotlib
- Show that $2+\sqrt{2}$ is not rational.
- What is training? When and why it is needed?
- What is a psychometric test? When is it conducted?
- When lignite is formed, it is converted into_______.
- State two observations which show that atom is not indivisible.
- Why SHOW DBS does not show my databases in MongoDB?
- Why it hurts when someone pulls hair but not when he goes for a haircut?

Advertisements