Cobweb
Cobweb
A class used to represent a Cobweb plot and a time series to study the convergence of a map.
Methods
- plot : Creates two figures, one containing the Cobweb plot and other with the time series.
- add_slider : Adds a slider which can change the value of a parameter in execution time.
- initial_position_slider : Adds a slider for changing initial value on a cobweb plot.
Source code in phaseportrait/Cobweb.py
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
__init__(dF, initial_position, xrange, *, dF_args={}, yrange=[], max_steps=100, n_points=10000, **kargs)
Cobweb
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dF |
function)
|
Map function, which returns value given a point and some parameters. |
required |
initial_position |
float)
|
Initial position for iterating the map. |
required |
xrange |
float or list)
|
Range of representation on x axis. |
required |
dF_args |
dict, optional)
|
Dictionary with parameters for |
{}
|
yrange |
float or list, optional)
|
Range of representation on y axis. |
[]
|
max_steps |
int, optional)
|
Number of iterations of the map. |
100
|
n_points |
int, optional)
|
Number of points to plot the map. |
10000
|
xlabel |
str, optional)
|
x axis label in the plot. Default value is |
required |
ylabel |
str, optional)
|
y axis label in the plot. Default value is |
required |
Title |
str, optional)
|
title of the plot. Default value is |
required |
Source code in phaseportrait/Cobweb.py
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 |
|
add_slider(param_name, *, valinit=None, valstep=0.1, valinterval=10)
Adds a slider on an existing plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_name |
str)
|
The string key of the variable. Must be the same as the key in the |
required |
valinit |
float)
|
Initial value of the parameter. |
None
|
valinterval |
Union[float, list])
|
The range of values the slider of the parameter will cover. |
10
|
valstep |
float)
|
Precision in the slider. |
0.1
|
Source code in phaseportrait/Cobweb.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
initial_position_slider(*, valinit=None, valstep=0.05, valinterval=None)
Adds a slider for changing initial value on a cobweb plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
valinit |
float, optional)
|
Initial position. Default value is the same as initial position given when initializing Cobweb object. |
None
|
valinterval |
Union[float, list])
|
The range of values the slider of the parameter will cover. |
None
|
valstep |
float)
|
Precision in the slider. |
0.05
|
Source code in phaseportrait/Cobweb.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
plot(*args, **kargs)
Prepares the plots, compute the values and plots them.
Returns:
Type | Description |
---|---|
tuple[matplotlib Figure (Cobweb plot), matplotlib Axis (Cobweb plot), matplotlib Figure (Time series), matplotlib Axis (Time series)]
|
|
Source code in phaseportrait/Cobweb.py
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 |
|
update_dF_args()
Internally used method. It is used for setting the new values of dF_args and also for initial position.
It is meant to be called on call
method in Slider class.
Source code in phaseportrait/Cobweb.py
166 167 168 169 170 171 172 173 174 175 176 177 |
|