2.2. Configuring Spyder#

Spyder is a general purpose programming environment for scientific applications, and it suits very well biomechanical data processing. We however recommend doing these steps to enhance your experience with interactive data processing.

Fig. 2.1 The Scientific Python Development Environment (spyder)#

2.2.1. Mandatory: Interactive Matplotlib figures#

To pan and zoom plots, or to use Kinetics Toolkit’s interactive functions (e.g., editing events, visualizing 3D points), you must use an interactive frontend for Matplotlib. Follow these steps to configure Spyder for interactive graphics, as shown in Fig. 2.2.

  • Go to the Spyder’s preferences

  • to the IPython console item

  • then to the Graphics pane.

  • In the Graphics backend box, select Qt5, then restart Spyder.

Fig. 2.2 Enabling interactive graphics in Spyder#


If you are not using Spyder (but you do use an IPython console), or you do not want to change your Spyder configuration, you can enable interactive graphics temporarily by typing:

%matplotlib qt5

2.2.2. Optional: Automatic code style#

While most Python code is generally readable, there are still many official and unofficial rules that define how code “should” look. For example, we usually put spaces between operators, no more than two blank lines between statements, etc. To focus on learning what to code rather than how code should look, we recommend to use the Black formatter. Follow these steps, as shown in Fig. 2.3:

  • Go to the Spyder’s preferences

  • to the Completion and linting item

  • then to the Code style and formatting pane.

  • In the Code formatting box, select black and check Autoformat files on save.

Now, your code will always respect most common style rules.

Fig. 2.3 Enabling Black formatter in Spyder#

2.2.3. Optional: Docstring linting#

If you start writing lots of functions, you will want your functions to be well documented. To help you in this objective, activate Docstring linting, which will provide hints in the editor to help you formatting your docstrings. Follow these steps, as shown in Fig. 2.4:

  • Go to the Spyder’s preferences

  • to the Completion and linting item

  • then to the Docstring style pane.

  • Check Enable docstring type linting and choose Numpy in the selection box.

Fig. 2.4 Enabling docstring linting in Spyder#