I wanted to ask about “ion()”. I’ve started learning Brian2 one month ago, but I’ve never seen “ion()” before on Tutorial (https://brian2.readthedocs.io/en/stable/advanced/interface.html). Could you tell please what is the functionality of “ion()” what does “ion()” do?
import brian2 as b2
I was working on this source https://github.com/zxzhijia/Brian2STDPMNIST which is the brian2 version of main Diehl&Cook’s program.
I had this “ion()” from there.
Ah, this is indeed quite confusing because the code you link to uses
ion function is not actually a Brian function, but it comes directly from
matplotlib (as explained here, Brian imports everything from
matplotlib automatically, which can lead to this kind of confusion). It is used to switch to the “interactive mode”, which is explained in more detail in the matplotlib documentation. Whether you need it or not depends on how you run Brian code: it does not do anything in a jupyter notebook for example. In a script or in an interactive Python console it means that a call to
plot will directly show the plot, instead of waiting for a
Note that there are various ways to find out what a function does in Python. For example, in a jupyter notebook you could type
b2.ion? to get help, and in a standard Python console you could type
PS: I took the liberty to change the title of your question to avoid confusion with the
brian2tools package. I also slightly reformatted your question, note that for Python code you can enclose it in
← here goes your code
to get it displayed nicely.
Thank you Mr. @mstimberg. for your detailed explanations.
You are welcome! Just one more general comment about using the forum: if you think that your issue is solved, please click on “…” below the reply that solved it and mark it as the “ Solution”. This makes it easier for us to keep track of which questions are still unanswered.