Matplotlib not showing plot when program is executed in the VS Code terminal

Viewed 772

I have this simple program here

import numpy as np 
import matplotlib.pyplot as plt 

num_of_intervals = 2000
x = np.linspace(-10,10,num=num_of_intervals)

y_inputs = 1/(1+np.exp(-x)) # SIGMOID FUNCTION

plt.figure(figsize = (15,9))
plt.plot(x,y_inputs,label = 'Sigmoid Function')
plt.vlines(x=0, ymin = min(y_inputs), ymax=max(y_inputs), linestyles='dashed')
plt.title('Sigmoid Function')
plt.show()

When the above program is ran in the vscode terminal. The plot cannot be seen (usually a pop-up window appears showing the plot).

But when the program is ran in the Ubuntu terminal, the plot can be seen as a pop-up window.

Any idea how I can solve this issue with vscode.

OS : Ubuntu 20.04

Visual Studio Code 1.54.3

Python : 3.8.5

1 Answers

Double check that this option is turned on in Settings: terminal.integrated.inheritEnv

Related