File: examples-misc_realtime_plotting.txt

package info (click to toggle)
brian 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 23,436 kB
  • sloc: python: 68,707; cpp: 29,040; ansic: 5,182; sh: 111; makefile: 61
file content (61 lines) | stat: -rw-r--r-- 1,773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.. currentmodule:: brian

.. index::
   pair: example usage; subplot
   pair: example usage; plot
   pair: example usage; run
   pair: example usage; trace
   pair: example usage; show
   pair: example usage; raster_plot
   pair: example usage; ioff
   pair: example usage; ion
   pair: example usage; Connection
   pair: example usage; RecentStateMonitor
   pair: example usage; SpikeMonitor
   pair: example usage; NeuronGroup

.. _example-misc_realtime_plotting:

Example: realtime_plotting (misc)
=================================

Realtime plotting example

::

    
    # These lines are necessary for interactive plotting when launching from the
    # Eclipse IDE, they may not be necessary in every environment.
    import matplotlib
    matplotlib.use('WXAgg') # You may need to experiment, try WXAgg, GTKAgg, QTAgg, TkAgg
    
    from brian import *
    ###### Set up the standard CUBA example ######
    N = 4000
    eqs = '''
    dv/dt = (ge+gi-(v+49*mV))/(20*ms) : volt
    dge/dt = -ge/(5*ms) : volt
    dgi/dt = -gi/(10*ms) : volt
    '''
    P = NeuronGroup(N, eqs, threshold= -50 * mV, reset= -60 * mV)
    P.v = -60 * mV + 10 * mV * rand(len(P))
    Pe = P.subgroup(3200)
    Pi = P.subgroup(800)
    Ce = Connection(Pe, P, 'ge', weight=1.62 * mV, sparseness=0.02)
    Ci = Connection(Pi, P, 'gi', weight= -9 * mV, sparseness=0.02)
    
    M = SpikeMonitor(P)
    trace = RecentStateMonitor(P, 'v', record=range(5), duration=200 * ms)
    
    ion()
    subplot(211)
    raster_plot(M, refresh=10 * ms, showlast=200 * ms, redraw=False)
    subplot(212)
    trace.plot(refresh=10 * ms, showlast=200 * ms)
    
    run(1 * second)
    
    ioff() # switch interactive mode off
    show() # and wait for user to close the window before shutting down