In 2020, I wrote my Master thesis for the Master of Aerospace Engineering (on the fascinating MMX mission which goes to one of the moons of Mars in 2024). Naturally, one wants to have clear and beautiful plots for such a personal work and academic achievement. In this short post, I outline how I approached this, and I share the code that I used to make all my plots in my thesis.
The scripts I used are found on Github: github.com/HaralDev/TUDelft_thesis_plotting
To give some context: I had hundreds of tests with the same types of data, yet with different tests cases (e.g. long tests, shorts tests, tests with big movements, small movements). Thus, I wanted to extract different type of plots. I show one of these plot functions in this minimum working example.
I used one Python script (.py) to setup the fonts, colours, size of plot: this is minimum_working.py. In this script I also define the functions for different test cases/plots — plot_positions_with_error_and_power() function for example produces the plot above.
I used a Notebook script (.ipynb) to organise the different type of plots and data sources — in my case, I grouped certain test cases together. I omitted this script as it is rather specific, but you can see an example below.
Custom font — Utopia
The Github includes the download link to the Utopia font which is used in the TU Delft template.
- Use consistent and clear colours for lines
- Use understandable filenames for your plot — perhaps even plot titles
- Same goes for line types (e.g. dotted)
- Avoid clutter — vary line thickness with amount of datapoints, separate plots (see plot above)
- Don’t use the Jet colormap. Source: https://www.youtube.com/watch?v=xAoljeRJ3lU
- Organise yourself, the Python Notebook should help with that
- Plot in PDF format — always
Stand on the shoulders of giants
Don’t try to reinvent the wheel. I found inspiration on the web, most notably from:
- Plot sizing and font: jwalton.info/Embed-Publication-Matplotlib-Latex
- Matplotlib basics: https://towardsdatascience.com/all-your-matplotlib-questions-answered-420dd95cb4ff
- Matplotlib basics 2: https://github.com/rougier/matplotlib-tutorial
- Plotting rules: journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003833
- 50 good plots: https://www.machinelearningplus.com/plots/top-50-matplotlib-visualizations-the-master-plots-python/
- And of course papers from my field
I hope this article can help you, if you need help with the scripts that I wrote, feel free to contact me!