No plot shows up from VS Code

Viewed 2942

I initiated the VS Code window through a WSL Ubuntu terminal such as

/mnt/d/github/python/python_for_data_science$ code .

And test a plot

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 5, 11)
y = x**2

# functional
plt.plot(x, y)
plt.show()

By Run Python File in Terminal, it shows

/mnt/d/github/python/python_for_data_science$ /usr/bin/python /mnt/d/github/python/python_for_data_science/section_8_matplotlib.py

But I didn't see a plot. Have I missed something?

1 Answers

WSL might not have the ability to show UI. Alternatively you can run the code in the Python Interactive window in order to see the output. Try right-click and select Run Current File in Python Interactive window.

Related