The Most Underrated and Underutilized Features of Matplotlib
Matplotlib is far more capable than most users think.
I have been using matplotlib for many years now.
Based on that, I believe that one of the best yet underrated and underutilized potentials of matplotlib is the amount of customizability it can offer.
But being unaware of that, most matplotlib users use it as a naive plotting utility with almost zero customization.
And as the default plots never appear “appealing”, they resort to other libraries, Plotly, for instance, to create elegant plots.
Yet, I firmly believe that in 90-95% of cases, you would NEVER need to look beyond matplotlib.
It can do much more than what most users think.
For instance, consider the two plots below:
Yes! Both plots were created using matplotlib.
But some custom formatting makes the second plot much more elegant, informative, appealing, and easy to follow.
The title and subtitle significantly aid the story.
Also, the footnote offers extra important information, which is nowhere to be seen in the basic plot.
Lastly, the bold bar immediately draws the viewer’s attention and conveys the purchase category’s importance.
Thus, in my opinion, the overwhelming potential for customization makes matplotlib far more capable than what most users think.
A departing lesson
One of the things I always ensure towards being a good storyteller in my data science projects is that my plot must demand minimal effort from the viewer.
Thus, I never shy away from putting in that extra effort.
This has been especially true for professional environments.
At times, it is also good to ensure that our visualizations convey the right story, even if they are viewed in our absence.
The below plot is a classic example of that.
In this entire post, I never discussed what that plot is about — somewhat indicating my absence.
Yet, by staring at this plot for a few seconds, you can quickly figure out what I intended to highlight here, can’t you?
You can download the code notebook for this post here: Matplotlib Notebook.
👉 Over to you: What are some other underrated gems of matplotlib that most users aren’t aware of?
👉 If you liked this post, don’t forget to leave a like ❤️. It helps more people discover this newsletter on Substack and tells me that you appreciate reading these daily insights.
The button is located towards the bottom of this email.
Thanks for reading!
Latest full articles
If you’re not a full subscriber, here’s what you missed last month:
Federated Learning: A Critical Step Towards Privacy-Preserving Machine Learning
You Cannot Build Large Data Projects Until You Learn Data Version Control!
Why Bagging is So Ridiculously Effective At Variance Reduction?
Sklearn Models are Not Deployment Friendly! Supercharge Them With Tensor Computations.
Deploy, Version Control, and Manage ML Models Right From Your Jupyter Notebook with Modelbit
Gaussian Mixture Models (GMMs): The Flexible Twin of KMeans.
To receive all full articles and support the Daily Dose of Data Science, consider subscribing:
👉 Tell the world what makes this newsletter special for you by leaving a review here :)
👉 If you love reading this newsletter, feel free to share it with friends!
Although I agree in general, as most people don't spent time learning matplotlib properly, the real reason why we move away from matplotlib towards other libraries is because matplotlib is not very pythonic and it is not obvious how to achieve things as there are at least three completely different ways creating plots and figures. That feels cluttered, ugly and error prone and you always have to look up all the nitty details. Seaborn, on the contrary, is much simpler, more straightforward and just easy to use, and it works very well with pandas DataFrames, which is the second most important thing. We want libraries that fit well the ecosystem. But matplotlib is and always will be very important as it is the foundation. But I appreciate that we have higher level libraries that do the main work and only then we can do ela deep dive into matplotlib to change whatever needs to be changed but only if we need it and not from the beginning just to get something good looking and complete.
Interesting read, good to know matplotlib is more versatile than meets the eye, please do share a couple of lines of your MatPlotLib recipe, that would be really helpful!