1

I am a beginner in Python and have a very basic question. In the matplot library we have show() function. I just want to know what is the benefit of using show() function.

For ex. if we have multiple statements such as

plt.scatter(XX,YY)
plt.plot(X,Y)
plt.show()     #3rd statement, is it necessary?

We can plot a scatter plot and can superimpose plot on it just by executing these two statements. Whether we write the 3rd statement i.e. plt.show() hardly matters. Does it matter? When do we use plt.show().

Please explain. Thank You.

1
  • I am afraid, it does not. Commented Jul 13, 2019 at 9:53

1 Answer 1

1

I'm afraid that i understand your question exactly.

'plt.show()' function do visualize your plot. And plt.scatter() and plt.plot() can't visualize its data independently. But you can do it, if you use jupyter-notebook with '%matplotlib inline' command. It helps to show plots without 'plt.show()' command.

Sign up to request clarification or add additional context in comments.

3 Comments

I am able to visualize both plt.scatter() and plt.plot() without using plt.show() in Spyder. What is the use of plt.show() then?
Spyder tool also helps you can see the graph without show() function.
You can try the same python code at pure console (powershell or ubuntu bash) and you may see the difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.