<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=VS_Code_Python_Interactive_window</id>
	<title>VS Code Python Interactive window - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=VS_Code_Python_Interactive_window"/>
	<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=VS_Code_Python_Interactive_window&amp;action=history"/>
	<updated>2026-04-16T13:53:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=VS_Code_Python_Interactive_window&amp;diff=303&amp;oldid=prev</id>
		<title>Davrot at 15:43, 17 October 2025</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=VS_Code_Python_Interactive_window&amp;diff=303&amp;oldid=prev"/>
		<updated>2025-10-17T15:43:04Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:43, 17 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== The goal ==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Python Interactive window allows you to interactively develop code with VS Code.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Python Interactive window allows you to interactively develop code with VS Code.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=VS_Code_Python_Interactive_window&amp;diff=58&amp;oldid=prev</id>
		<title>Davrot: Created page with &quot; == The goal == Python Interactive window allows you to interactively develop code with VS Code.  Questions to [mailto:davrot@uni-bremen.de David Rotermund]  &#039;&#039;&#039;Please use # %% with .py files instead of .ipynb Jupyter notebook files for interactive cells!!!&#039;&#039;&#039;  If you don’t know what I am talking about, please read: [https://code.visualstudio.com/docs/python/jupyter-support-py Python Interactive window]  == Executing a cell == In the cell mode (# %%) you can use * SHIF...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=VS_Code_Python_Interactive_window&amp;diff=58&amp;oldid=prev"/>
		<updated>2025-10-14T15:00:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; == The goal == Python Interactive window allows you to interactively develop code with VS Code.  Questions to [mailto:davrot@uni-bremen.de David Rotermund]  &amp;#039;&amp;#039;&amp;#039;Please use # %% with .py files instead of .ipynb Jupyter notebook files for interactive cells!!!&amp;#039;&amp;#039;&amp;#039;  If you don’t know what I am talking about, please read: [https://code.visualstudio.com/docs/python/jupyter-support-py Python Interactive window]  == Executing a cell == In the cell mode (# %%) you can use * SHIF...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== The goal ==&lt;br /&gt;
Python Interactive window allows you to interactively develop code with VS Code.&lt;br /&gt;
&lt;br /&gt;
Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Please use # %% with .py files instead of .ipynb Jupyter notebook files for interactive cells!!!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If you don’t know what I am talking about, please read: [https://code.visualstudio.com/docs/python/jupyter-support-py Python Interactive window]&lt;br /&gt;
&lt;br /&gt;
== Executing a cell ==&lt;br /&gt;
In the cell mode (# %%) you can use * SHIFT + ENTER to execute a cell or * CTRL + ENTER.&lt;br /&gt;
&lt;br /&gt;
The former moves the cursor into the next cell, while the later keeps the cursor that the original position.&lt;br /&gt;
&lt;br /&gt;
== [https://matplotlib.org/ipympl/ Interactive plotting in # %% cells​] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;pip install ipympl&amp;lt;/syntaxhighlight&amp;gt;We can activate the interactive plotting mode via&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;%matplotlib widget ​&amp;lt;/syntaxhighlight&amp;gt;The first time we use this command, vs code will need to download a plugin).&lt;br /&gt;
&lt;br /&gt;
Here an example:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;# %%&lt;br /&gt;
%matplotlib widget&lt;br /&gt;
&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
&lt;br /&gt;
plt.plot(np.sin(np.linspace(0, 20, 100)))&amp;lt;/syntaxhighlight&amp;gt;Yes, mypy will give you an error and yes, you can not suppress it… but non you can zoom and pan the figure… You can not have everything at once!&lt;br /&gt;
&lt;br /&gt;
=== Modifing a plot ===&lt;br /&gt;
First we plot something but keep the handle:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;# %%&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
import numpy as np&lt;br /&gt;
&lt;br /&gt;
fig = plt.figure()&lt;br /&gt;
line = plt.plot(np.sin(np.linspace(0, 20, 100)))&amp;lt;/syntaxhighlight&amp;gt;Then we can use to change the plot using the handle:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;# %%&lt;br /&gt;
line[0].remove()&lt;br /&gt;
line = plt.plot(np.sin(5.0*np.linspace(0, 20, 100)))&amp;lt;/syntaxhighlight&amp;gt;If you don’t know the handle, you can retrieve it like this:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;# %%&lt;br /&gt;
handles = fig.gca().get_children()&lt;br /&gt;
print(handles)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;[&amp;lt;matplotlib.lines.Line2D object at 0x7fe130f75310&amp;gt;, &amp;lt;matplotlib.spines.Spine object at 0x7fe130f1d710&amp;gt;, &amp;lt;matplotlib.spines.Spine object at 0x7fe130f1dcd0&amp;gt;, &amp;lt;matplotlib.spines.Spine object at 0x7fe130f1e210&amp;gt;, &amp;lt;matplotlib.spines.Spine object at 0x7fe130f1e750&amp;gt;, &amp;lt;matplotlib.axis.XAxis object at 0x7fe130f1ecd0&amp;gt;, &amp;lt;matplotlib.axis.YAxis object at 0x7fe1310b7350&amp;gt;, Text(0.5, 1.0, &amp;#039;&amp;#039;), Text(0.0, 1.0, &amp;#039;&amp;#039;), Text(1.0, 1.0, &amp;#039;&amp;#039;), &amp;lt;matplotlib.patches.Rectangle object at 0x7fe130f3cf10&amp;gt;]&amp;lt;/syntaxhighlight&amp;gt;This allows us to do this:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;# %%&lt;br /&gt;
fig.gca().get_children()[0].remove()&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Re-Plotting ===&lt;br /&gt;
You can use&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;# %%&lt;br /&gt;
display(fig)&amp;lt;/syntaxhighlight&amp;gt;for replotting the plot. However you will get a message from VS Code that display is not defined. It is defined but it doesn’t know it.&lt;/div&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
</feed>