Visualization of Data

Visual communication of results from analysis. The story told by the images should enhance the understanding of the viewer versus viewing raw data or equations.

Visual representation of data:

"information that has been abstracted in some schematic form, including attributes or variables for the units of information"

Data visualization is both an art and a science. The are many good and bad examples of what should be done.


In [15]:
from IPython.display import Image
from IPython.core.display import HTML 
Image(url= "https://upload.wikimedia.org/wikipedia/commons/b/ba/Data_visualization_process_v1.png" 
      ,height=400, width=550)


Out[15]:

The are a number of packages that we could use to present the data. In this case we will be exploring the use of matplotlib. Use '%matplotlib inline' line in your ipython notebook to activate the inline viewing of the plots


In [26]:
%matplotlib inline
import pandas as pd
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.plot(np.arange(10))


Out[26]:
[<matplotlib.lines.Line2D at 0xe4a0240>]

In [27]:
#Plots in matplotlib reside in a figure object. Create a new figure object with 
plt.figure()


Out[27]:
<matplotlib.figure.Figure at 0xe33e470>
<matplotlib.figure.Figure at 0xe33e470>

In [29]:
fig = plt.figure()


<matplotlib.figure.Figure at 0xe33e630>

In [32]:
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,3)
#Empty Matplotlib figure with three subplots
fig


Out[32]:

In [34]:
plt.plot(randn(50).cumsum(),'k--')


Out[34]:
[<matplotlib.lines.Line2D at 0xed51ba8>]

k-- is a style option for black dashed lines


In [46]:
_ = ax1.hist(randn(100), bins=20, color='k', alpha=0.3)
ax2.scatter(np.arange(30), np.arange(30) +3 * randn(30))


Out[46]:
<matplotlib.collections.PathCollection at 0xefaaf60>

In [47]:
fig


Out[47]:

In [ ]: