Matplotlib image does not appear in Visual Studio Code on Mac

I have the base code in the Visual Studio Code editor on MacOSX:

    import matplotlib.pyplot as plt
    import numpy as np
    x = np.linspace(0, 20, 100)
    plt.plot(x, np.sin(x))
    plt.show()

... and it may not seem that the png / svg file image appeared after starting this. This also does not stop execution, and I have to manually terminate the process. However, if I run this directly in the terminal (each line of line of code for the line), I get the resulting image. One of them is just to save the file (plt.savefig ('foo.png')). This seems to work - the image is saved at the specified file location. However, it would be nice to see how the image appears after running the code.

0
source share
1 answer

matplotlib . " ", , - . :

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show(block=False)
input('press <ENTER> to continue')

, , ENTER . , .

+1

Source: https://habr.com/ru/post/1693051/


All Articles