In this markdown we describe teh plotting functions available with RatInABox
. The following definitions hold:
Env
: a 2DEnvironment()
class with a wall and solid boundary conditionsEnv1D
: a 1DEnvironment()
class with periodic boundary conditions
Displays the environment. Works for both 1 or 2D environments. Examples:
Env.plot_environment()
Plots the agent trajectory. Works for 1 or 2D.
Ag.plot_trajectory(t_end=120)
Ag1D.plot_trajectory(t_end=120)
Makes an animation of the agents trajectory.
Plots a heatmap of the Agents past locations (2D and 1D example shown)
Plots a timeseries of the firing rates
Plots a timeseries of the firing rates as an image
Plots a timeseries of the firing rates
Makes an animation of the firing rates timeseries
Depending on the parameters passed this function will either
- Analytically calculate the rate map (
method = 'analytic'
), - Infer the rate map from past activity (
method = 'history'
) or - Plot the observed spikes (
spikes=True
). As an example here we show this function for a set of 3 (two dimensional) grid cells and 10 (one-dimensional) place cells.
Neurons.plot_rate_map(method=
analytic`)
Neurons.plot_rate_map(method=
history`)
Neurons.plot_rate_map(method=
neither`, spikes=True)
Scatters where the place cells are centres
- All plotting functions return a tuple (
fig
,ax
) ofmatplotlib
figure objects. - Most plotting functions support being passed
fig
andax
and will plot whatever it is they plot ontop of that. This means we can make:
- Layered figures (e.g. plot a trajectory on top of a rate map):
fig, ax = Neurons.plot_rate_map(chosen_neuron="1")
fig, ax = Ag.plot_trajectory(fig=fig, ax=ax)
- Multipanel figures:
fig, axes = plt.subplots(1,5,figsize=(20,4))
Ag.plot_trajectory(fig=fig,ax=axes[0])
Neurons.plot_rate_map(fig=fig,ax=[axes[1],axes[2],axes[3]],chosen_neurons='3') #<-- to plot more than 1 neuron pass an array of axes
Neurons.plot_rate_timeseries(fig=fig,ax=axes[4])
-
For rate maps and timeseries' by default all the cells will be plotted. This may take a long time if the number of cells is large. Control this with the
chosen_neurons
argument -
We use the
matplotlib
wrappertomplotlib
to format and save figures. This is not necesary for the workings ofratinabox
but note your figures might look slightly different without it.