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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
.. _hoc_grapher:
Grapher
-------
A tool for graphing any set of expressions as a function of
an independent variable.
The Grapher is similar to a "for" statement.
It iterates the independent variable over the range specified by the
"Indep Begin" and "Indep End" field editors using "Steps" steps.
At each step, it executes the statements
specified in the Generator field (if any), and plots the values that are
specified in the Graph scene from the :ref:`hoc_gui_PlotWhat` menu item at the x-axis
location specified by the value of the "X-expr" (normally the same
as the independent variable).
These y values and X-expr can be variable names or function names.
To pop up the widget say:
.. code-block::
none
load_file("grapher.hoc") // reads this file
makegrapher(1) // pop up a new grapher
Creating a grapher using
.. code-block::
none
makegrapher()
pops up a short form of the Grapher without "Indep Begin", "Indep
End", or "X-expr" buttons. The limits are defined by the x-axis length
of the current view.
Graphers may be saved in a .ses file.
To use the grapher widget:
1) enter the independent variable name (press the button) eg. x
2) enter the begin, end, and steps values.
3) specify the y variables:
in the graph panel press the left button and select "Plot What?"
and enter an expression or variable to plot. eg. sin(x)
You can do this several times to plot several expressions.
4) If the y variables are actual functions of the independent variable
press the Plot button to see the plot. If the y variables
are in fact just variables then you will need a generator
statement that tells how to compute the y variables given
a value of the independent variable. eg. Just for fun you can
try entering the generator statement: ``print x, sin(x)``
Example:
.. code-block::
none
Example 1: plot sin(t)
1) PlotWhat: sin(t)
2) Plot
Example 2: plot of steady state m process in nrniv
1) Independent Var: x
2) Generator: rates_hh(x)
3) IndepBegin -100, Indep End 50
4) Set View: x: -100 50 y: 0 1
5) PlotWhat: minf_hh
6) Plot
Example 3: In context of Neuron Main Menu simulation
0) pop up grapher by selecting appropriate "New Graph" submenu item.
1) Independent Var: v_init
2) Generator: init()
3) IndepBegin -100, Indep End 50
4) SetView: x: -100 50 y:cancel
5) PlotWhat: <any set of variables in any section>
6) Plot
Example 4: peak inward current during voltage clamp
Replace the standard: proc advance() {fadvance()} with a procedure
that stores the peak inward current (and possibly sets stoprun=1
when you are past the peak). Then in the Grapher set Steps to 20
the independent variable to the voltage clamp amplitude and the
generator to run().
Plot
~~~~
For each value of the independent variable the generator statement
is executed (if it exists) and the PlotWhat expressions are plotted.
EraseAll
~~~~~~~~
Removes all expressions from the graph.
Steps
~~~~~
Number of independent variable values used to make the graph.
For the small grapher, the range of the independent variable is
the length of the x-axis.
IndependentVar
~~~~~~~~~~~~~~
Dialog appears requesting the variable to be used as the independent
variable (default t). If the variable is undefined it will
be created.
Generator
~~~~~~~~~
A statement to be executed after setting a value of the independent
variable but before plotting the expressions. This allows plotting
of variables that depend implicitly on the independent variable.
IndepBegin
~~~~~~~~~~
For a grapher made with makegrapher(1), specifies initial value
of the independent variable.
IndepEnd
~~~~~~~~
Specifies final value of independent variable.
Xexpr
~~~~~
A grapher made with makegrapher(1) allows separate specification of
independent variable and the x axis plot functions. This allows
phase plane plots. The Xexpr may be any function of the independent
variable or an implicit function if a generator statement exists.
|