question

GiladPellaeon-3091 avatar image
0 Votes"
GiladPellaeon-3091 asked PengGe-MSFT commented

How to show matplotlib images in Visual Studio 2019 with Python

Atm I learn Python to do ML. I use Visual Studio 2019 as IDE (not Visual Studio code!). To show image data I installed and imported matplotlib. Here is an excerpt how I call matplotlib

 . . .
    
 for image_batch, label_batch in dataset.take(1):
     print(image_batch.shape)
     print(label_batch.numpy())
     plt.imshow(image_batch[0].numpy().astype("uint8"))
     plt.title(class_names[label_batch[0]])
     plt.axis("off")


My example code runs without an error. But the program only prints text in the console. There is no windows showing my picture. I tried to find a solution how to use matploblib in Visual Studio, but I only found information about how to achieve it in Visual Studio Code. What must I do or which extension must install to see the plotted images?

Best regards

vs-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @TrnQuangAnh-8212
I have not heard from you for a couple of days. Please let me know if there is anything that I can help here.

0 Votes 0 ·

1 Answer

PengGe-MSFT avatar image
0 Votes"
PengGe-MSFT answered

Hi, @GiladPellaeon-3091

Welcome to Microsoft Q&A!

You can try to add the following content to your code:

 plt.show()

Then try to run again.

Sincerely,
Peng


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.