Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: Explain the difference between `plt.show()` and `plt.savefig()` in Matplotlib.
Answer: `plt.show()` displays the plot interactively, while `plt.savefig()` saves the current figure to a file without displaying it.

Example:

plt.plot([1, 2, 3, 4], [10, 20, 25, 30])
plt.savefig('plot.png')
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook