Skip to main content


About the Matplotlib Prefab

Matplotlib Prefab is a repository based on matplotlib package, which provides several matplotlib ploting templates for line plot, hist plot, scatter plot, and some complex plottings. You can see the GitHub repository at https://github.com/cbhua/matplotlib-prefab.


Introduction

I have a passion for creating visually appealing figures in publications. During my time writing papers, I often dedicated significant effort to crafting plots. In this repository, I've compiled some of my previous `matplotlib` plotting source code and have designed several templates for convenient reuse. I've chosen not to package this content due to the myriad of customizable parameters. Instead, I believe a template approach is more straightforward to modify and repurpose. I hope these templates inspire you and provide techniques to craft beautiful `matplotlib` figures.


Environment

I've aimed to keep dependencies to a minimum; thus, a basic combination of matplotlib and numpy should suffice. However, it's important to note that I've incorporated LaTeX font families and formatting. Therefore, you'll need to have LaTeX installed on your operating system.


Python Version: 3.10 (develop)
Python Package: matplotlib 3.8 (support Latex text), numpy
Other: to use the Latex illustration style, the Latex is required to be installed
            

How to use

You can easily go to the home page: cbhua.github.io/matplotlib-prefab and see the example figures of each prefabs:

You can click on the figure to view the associated template code. Most of the code for these figures is self-contained and can be run independently. However, a few require external data. For those instances, please refer to the accompanying notebook.

You can also refer to the GitHub notebook directory to access Jupyter notebooks for those example figures and tailor them to your needs.

Have fun!