Home Machine Learning Matplotlib: Make Your Plotting Life Simpler with rcParams | by Mike Clayton | Feb, 2024

Matplotlib: Make Your Plotting Life Simpler with rcParams | by Mike Clayton | Feb, 2024

0
Matplotlib: Make Your Plotting Life Simpler with rcParams | by Mike Clayton | Feb, 2024

[ad_1]

Visualisation

Constantly stunning plots with much less code and minimal effort

A boxplot comparing fake earnings data between industries with styling using matplotlib’s rcParams
A boxplot utilizing rcParams for styling — Picture by Creator

Matplotlib is undoubtedly a strong and extensible plotting library, but it surely may also be frustratingly sophisticated, and particularly, very verbose.

rcParams (runtime configuration parameters) present a means of extracting a number of the boilerplate code right into a configuration file. This ends in considerably much less repeated code, and constantly stunning and properly laid out plots. It additionally makes your setup and styling replicable, and simply transportable between initiatives.

As I discussed in my earlier article that in contrast Matplotlib to a number of the different widespread plotting libraries (equivalent to Seaborn or plotnine):

It [Matplotlib] is pretty ubiquitous within the area of knowledge science, and it could be truthful to say that lots of people have a love-hate relationship with it. It is rather versatile, however may also get fairly concerned.

Me in my earlier article

“Fairly concerned” may very well be numerous issues. Specifically it turned fairly apparent that every one the opposite libraries excelled at one factor that Matplotlib didn’t. They might all generate fairly engaging properly laid out plots with little or no code enter.

They [the alternative plotting libraries] may all generate fairly engaging properly laid out plots with little or no code enter.

So is there a means that Matplotlib can compete with this immediate gratification, with out dropping the flexibleness and plotting prowess it’s well-known for? As identified by one of many commenters of that earlier article it definitely is:

Alternatively, sure — matplotlib is ugly by default. However as you retain on studying it, you’ll get to know the so referred to as `rcParams` — a file that gives all of the preliminary plot settings.

Pawel Jastrzebski

…and he’s proper. So let’s see how this may be put into motion.

[ad_2]