Python Data Visualization with Matplotlib

python_tutorials

Introduction

Visualizing data trends is one of the most important tasks in data science and machine learning. The choice of data mining and machine learning algorithms depends heavily on the patterns identified in the dataset during data visualization phase. In this article, we will see how we can perform different types of data visualizations in Python. We will use Python’s Matplotlib library which is the de facto standard for data visualization in Python.

The article A Brief Introduction to Matplotlib for Data Visualization provides a very high level introduction to the Matplot library and explains how to draw scatter plots, bar plots, histograms etc. In this article, we will explore more Matplotlib functionalities.

Changing Default Plot Size

The first thing we will do is change the default plot size. By default, the size of the Matplotlib plots is 6 x 4 inches. The default size of the plots can be checked using this command:

import matplotlib.pyplot as plt

print(plt.rcParams.get('figure.figsize'))

For a better view, may need to change the default size of the Matplotlib graph. To do so you can use the following script:

fig_size = plt.rcParams["figure.figsize"]
fig_size[0] = 10

To finish reading, please visit source site