Saving and manipulating plots#
Saving or manipulating plots is easy. All thebeat’s plotting functions internally use matplotlib. The functions return a matplotlib.figure.Figure
object, representing the entire plot, and a matplotlib.axes.Axes
object, which represents the actual graph in the plot. These objects we can use to save or manipulate the plots.
Saving plots#
In the example below we create a recurrence plot, and save it to disk using savefig()
. We ask for a plot with a dpi of 600, so we get better quality.
[11]:
from thebeat import Sequence
from thebeat.visualization import recurrence_plot
seq = Sequence(iois=[300, 400, 300, 400])
fig, ax = recurrence_plot(seq, dpi=600)
fig.savefig('recurrence_plot.png')
Adding in title, x_axis label etc.#
thebeat’s plotting functions contain a few arguments for commonly encountered manipulations, such as adding in a title, changing the figure size, etc. These are the so-called keyword arguments (**kwargs
).
To see a list of available keyword arguments, see e.g. thebeat.helpers.plot_single_sequence()
.
Manipulating plots#
Manipulating plots works similarly. We can use the resulting matplotlib.figure.Figure
and matplotlib.axes.Axes
objects for manipulation, and only show the figure afterwards.
[12]:
fig, ax = recurrence_plot(seq, suppress_display=True)
ax.set_xticklabels([0, 1, 2, 3, 4], fontsize=18)
fig.show()
More info on how to manipulate plots can be found in the matplotlib documentation.