NewToTheGame
NewToTheGame

Reputation: 13

How to print out matplotlib in VS Code

Just a small question. I have VS Code installed and trying it out with Python but no matter what I try I cannot get matplotlib plots to appear.

Here is a simple code that does NOT work

import mglearn
import matplotlib.pyplot as plt

X, y = mglearn.datasets.make_wave(n_samples=40) 
plt.plot(X, y, 'o') 
plt.ylim(-3, 3) 
plt.xlabel("Feature") 
plt.ylabel("Target")

No error with the code appears but also no plot. Thanks.

Please note mglearn comes from the following Github https://github.com/amueller/mglearn

Upvotes: 1

Views: 9320

Answers (2)

user3408085
user3408085

Reputation: 130

Try plt.show() at the end. And this additional line is just because the system asks me extra text for no reason.

Upvotes: 3

abc
abc

Reputation: 11929

Your code works. You need to ask for the picture to be shown plt.show() or to be saved plt.savefig().

Just add plt.show() and you will obtain:

enter image description here

Upvotes: 0

Related Questions