Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 1.64 KB

README.md

File metadata and controls

12 lines (7 loc) · 1.64 KB

Creating custom Matplotlib style

This repository consists of two Jupyter notebooks to demonstrate how to create and use custom styles in Matplotlib. The first notebook Data_Visualisaton_Example customises three sample graphs using matplotlib's inline customisations. The main drawback here is that these customisations must be applied to every graph in a project. This can be overcome by creating a .mplstyle file which holds all the needed customisations in a single place. The repository consists of two .mplstyle files with varying levels of customisations.

The second notebook, Data_Visualisation_Example_with_mplstyle does the same customisations as the previous notebook with one difference. It makes use of demo_style.mplstyle file to customise its graphs. The key advantage here is that you just need to add line of code instead of adding customisations to every graph. The line plt.style.use(demo_style.mplstyle) is all it takes to instruct Matplotlib to use this file for applying customisations to all the graphs in a given Jupyter notebook or a python script.

A couple of comparisons between Matplotlib's styles and a custom demo_style_2.mplstyle.

All vs custom wave All vs custom bar

If you wish to change the style of a single graph or chart while using .mplstyle, you can always override the custom style using inline customisations. Using inline customisation does not affect the .mplstyle file and the customisation will apply only to that graph or chart.