Plotting graphs using python and Matplotlib

Allwin Raju
5 min readOct 8, 2021
Photo by Isaac Smith on Unsplash

This article focuses on plotting different types of graphs such as line charts, bar charts, pie charts, and scatter plots using Matplotlib, which is arguably the most popular graphing and data visualization library for Python.

Graphs are mathematical structures that represent pairwise relationships between objects.

Matplotlib

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Matplotlib makes easy things easy and hard things possible.

The easiest way to install matplotlib is to use pip. Type following command in terminal:

pip install matplotlib

or, you can download it from here and install it manually.

Steps involved in plotting a graph

  • Define the x-axis and corresponding y-axis values as lists.
  • Plot them on canvas using .plot() function.
  • Give a name to x-axis and y-axis using .xlabel() and .ylabel() functions.
  • Give a title to your plot using the .title() function.
  • Finally, to view your plot, we use the .show() function.

Plotting a line graph

--

--

No responses yet