Running Python 3.6.5 in VS Code.The script says import matplotlib.pyplotasplt
, but plt.show()
also shows the plot window, but nothing is drawn and the window remains completely white.There is no error message.
plt.show()
is preceded by various processing and the result is code such as plt.plot(x,y,label="result")
.It came out when I ran on IDLE before.Now I'm building with Homebrew and Pyenv and putting in VS Code.
The plot does not appear even with simple codes such as:
import numpy as np
import matplotlib.pyplot asplt
# Output line graph
left = np.array ([1, 2, 3, 4, 5])
height = np.array ([100, 300, 200, 500, 400])
plt.plot(left, height)
And the terminal window under VSCode has
/Users/user1/Desktop; env "PYTHONIOENCODING=UTF-8" "PYTHONUNBUFFERED=1"/Users/user1/.pyenv/versions/3.6.5/bin/python/Users/user1/.vscode/extensions/messon.python.psycho/psycho/psycho/mys-psycho-psycho-pers.pers.pys.pys.pys.pys.pys.pys.pys.pys.pys
appears.
Please let me know what caused it.
python matplotlib
If you run IDLE, but you don't get a plot even with simple code in a Pyenv+VSCode environment, it's not a code problem, it's probably a problem with your environment.
Both Pyenv and VSCode are useful tools, but some parts are black boxed, so if they don't work the way you want, it takes time to find out.In this case, the following conditions are different from running on IDLE:
stings.json
Impact$HOME/.pyenv/bin
to the beginning of the PATH, which affects itTo resolve this issue, you must first change these conditions to find out where the problem lies.If you run with IDLE, it will be displayed, so you should try running with VSCode instead of IDLE and start with whether or not the plot will be printed.
© 2024 OneMinuteCode. All rights reserved.