Corporate identity styling of Python graphs using a stylesheet
Do you recognize feeling frustrated about the looks of the standard Python graphs? Or you just need your corporate identity to be reflected in these graphs to be able to directly use them in a presentation? Well, I feel you! This is exactly the problem I ran into when happily working within my Python scripts and notebooks.
So, when my colleague Wouter van Gils showed me the corporate identity template he created for R, I decided to follow his lead and do exactly that for Python as well.
Luckily, this is actually quite straightforward in Python. We can create our own style by using the elaborate example that can be found in the matplotlib documentation. In my case I chose to only add the elements that I wanted to change and save the file as cmotions.mplstyle.
For me, the content of the file looks like this:
Only thing I need to do before creating graphs is to add the following two lines of code to my script or notebook:
After running these lines my corporate identity theme will not only be used by matplotlib, but also when creating graphs using seaborn and pandas.
In the next code example you can see how I use my corporate identity style in Python.
Of course more changes can be made, depending on your needs. I hope this basic example is useful to you when you want your corporate identity reflected in your Python output.
Enjoy creating your own corporate identity theme!
Want to read more about the cool stuff we do at Cmotions and The Analytics Lab? Check out our blogs, projects and videos!