Visualization Tools

In this lesson, some visualization tools are explored.

We'll cover the following

This lesson reviews some of the tools and libraries that are used in this chapter to visualize various forms of data.

Matplotlib

Matplotlib is an interactive python graph-plotting library that helps us visualize data in various 2D plots. The following is an example of how matplotlib can be used to create a visualization of the Sin wave.

import numpy as npimport matplotlib.pyplot as plt# Get x values of the sine wavepoints = np.arange(0, 10, 0.1);# Plot a sine wave plt.plot(points, np.sin(points))# Give a title for the sine wave plotplt.title('Sine wave')# Give x axis label for the sine wave plotplt.xlabel('Time')# Give y axis label for the sine wave plotplt.ylabel('Amplitude')plt.show()

Seaborn

Seaborn is an extension of the matplotlib package and builds on top of the already provided matplotlib functions. It adds more interactivity in the already present plots providing more concise information. The following code is inspired by an example from seaborn documentation that plots a joint plot. It can also be found here.

import numpy as npimport pandas as pdimport seaborn as sns# Generate a random correlated bivariate datasetrs = np.random.RandomState(5)mean = [0, 0]cov = [(.5, 1), (1, .5)]var1, var2 = rs.multivariate_normal(mean, cov, 500).Tvar1 = pd.Series(var1, name="X-axis")var2 = pd.Series(var2, name="Y-axis")# Show the joint distribution using kernel density estimationsns1 = sns.jointplot(var1, var2, kind="scatter")

• Histogram

• Box

• Regression

• Heatmaps

• Scatter

• KDE