1

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

2
  • 1
    Did you mean VS Code instead of Visio, in the title and tags? Commented Aug 27, 2018 at 22:22
  • Looks like this has nothing to do with Microsoft Visio? I would also suggest you change the tags. Commented Aug 27, 2018 at 22:53

2 Answers 2

3

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

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

Comments

0

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

1 Comment

Thank you both for the answer...i tried to give both answers a check but not possible. Thanks again. Question resolved.

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.