1 year ago

#386136

test-img

S. U.

Using a devcontainer in VS Code, how can I display matplotlib plots?

I'm running an Ubuntu devcontainer inside VS Code. However, when I run a python script that creates a plot, the plot doesn't show up anywhere, even when using matplotlib.pyplot.show(). My guess is that the devcontainer just doesn't have any way of displaying it. My workaround right now is to save the plot using matplotlib.pyplot.savefig(), but that's not great when I just want to check something quickly.

Does anyone know how to see the plots created inside the devcontainer?

Here's an example of what I'd like to do:

import matplotlib.pyplot as plt
import numpy as np


# random data
x = np.linspace(0, 1, 100)
y = np.sin(np.pi * x)

# try plotting
plt.plot(x, y)
plt.show()

python

matplotlib

visual-studio-code

vscode-devcontainer

0 Answers

Your Answer

Accepted video resources