AISaturdaysOgbomoso Cohort 2, WEEK 3: Matplotlib.

Lautech DataScience
3 min readJan 23, 2019

--

Matplotlib is the “grandfather” library of data visualization with Python. It was created by John Hunter. He created it to try to replicate MatLab’s (another programming language) plotting capabilities in Python. So if you happen to be familiar with matlab, matplotlib will feel natural to you.

It is an excellent 2D and 3D graphics library for generating scientific figures.

Some of the major Pros of Matplotlib are:

  • Generally easy to get started for simple plots.
  • Support for custom labels and texts.
  • Great control of every element in a figure.
  • High-quality output in many formats.
  • Very customizable in general.

Matplotlib allows you to create reproducible figures programmatically. Let’s learn how to use it! Before you continue reading, I encourage you just to explore the official Matplotlib web page: http://matplotlib.org/

The class was really fun at first since we were still working with just plotting a simple line plots.

We all started with making sure we had matplotlib on our workspace by importing pyplot function in matplotlib.

After importing and confirming that matplotlib was installed since almost everyone installed anaconda which has the matplotlib library out of the box, we moved on to creating our first visualization, which was a line graph.

In the Command above we explained the use of %matplotlib inline and command plt.show(). Then we checked into Subplot: plotting more than one plot on a canvas and we didn’t make use of the plt.show() because of the %matplotlib inline which helps to print the plot without the plt.show() function in Jupyter Notebook.

Then we introduced ourselves to figure function( plt.figure() ) which helps to define the size of the canvas and how to position the plots in different templates.

Below is an example of 3 plots on the canvas with different size and shapes(with the use of axes).

We further talked about changing the colours of our graphs, the plot types, setting Legends and also label title and above all how to save our figures for use in presentation and visualization.

If we must confess though, it was a bit challenging but a good way to learn is by facing up to challenges😄. They were given another notebook for personal studies and from the feedback we got, some of them dug further into visualization 😍.

Thanks to our ambassador 0basa Samuel temitope for writing this and Daniel Ajisafe and Tejumade Afonja for guiding us.

AISaturdayOgbomoso wouldn’t have happened without our fellow ambassadors and coaches, our partners Intel .

follow us on https://twitter.com/LautechDataSci

--

--

Lautech DataScience

A community of data scientists and AI practitioners in LAUTECH.