close

How to show graph in Visual Studio Code itself

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to show graph in Visual Studio Code itself in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to show graph in Visual Studio Code itself?

  1. How to show graph in Visual Studio Code itself?

    You can split your code into cells using # %% as in this example. Running code this way, Visual Studio Code opens an Interactive pane that displays the plots inline.

  2. show graph in Visual Studio Code itself

    You can split your code into cells using # %% as in this example. Running code this way, Visual Studio Code opens an Interactive pane that displays the plots inline.

Method 1

Yes, if you use notebook interface. Basically, install Python Extension Pack, it includes Jupyter extension, put your code in the editor, put #%% at the top of your code, you’ll get Run cell clickable, click it, and you’ll get result in the other window

enter image description here

UPDATE

Ok, apparently Microsoft hired Don Jayamanne and he’s working on Python and Jupyter for VS Code. And last month they (MS) improved their python extension to support Jupyter notebooks right in the Visual Code together with .ipynb import and export. Get extension here and check blog post how to use it with Jupyter notebooks.

UPDATE II

Another one is Neuron, under development, but looks nice – again, notebooks in VS Code, with graphs, markdown etc. 

Method 2

Instead of using a Jupyter notebook you can use Visual Studio Code in Interactive mode. It is similar to a notebook in many ways, as it splits your code into cells that can be run individually. One advantage over notebooks is that this remains a normal .py file. Spyder IDE also has this feature.

You can split your code into cells using # %% as in this example. Running code this way, Visual Studio Code opens an Interactive pane that displays the plots inline.

# %%
import matplotlib.pylab as plt
import numpy as np

# %% 
plt.figure()
plt.plot(np.sin(np.linspace(-np.pi, np.pi, 1001)))
plt.show()

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read