In [62]:
    
%matplotlib inline
import matplotlib
import seaborn as sns
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
%cd C:\Users\da.angulo39\Documents\ipython_notebooks\Assignment1\Example1\data
#figure size
matplotlib.rcParams['figure.figsize'] = (10.0, 8.0)
    
    
In [63]:
    
vortex_file = "vorticity.asc"
in_file = open(vortex_file)
#first line contains dimension and spacing of grid
l = in_file.readline().split()
nx, ny = int(l[0]), int(l[1])
sx, sy = float(l[2]), float(l[3])
    
In [64]:
    
#initialize data object for speed
data = np.zeros((ny,nx))
    
In [65]:
    
for j in xrange(ny):
    l = in_file.readline().split()
    values = [float(x) for x in l]
    data[j,:] = values
in_file.close()
    
In [66]:
    
print data[5,5]
    
    
We can simply use the imshow method
In [67]:
    
plt.imshow(data)
    
    Out[67]:
    
We are going to use some of the colormaps defined in colorbrewer via seaborn
We will use 8 colors to illustrate the palettes
In [68]:
    
grayscale = sns.color_palette("Greys",8)
sns.palplot(grayscale)
    
    
In [69]:
    
hot = sns.color_palette("YlOrRd",8)
sns.palplot(hot)
    
    
In [70]:
    
hotcold = sns.color_palette("RdBu",8)
sns.palplot(hotcold)
    
    
In [71]:
    
rainbow = sns.color_palette("husl",8)
sns.palplot(rainbow)
    
    
In [72]:
    
plt.imshow(data,cmap=sns.blend_palette(grayscale,as_cmap=True))
    
    Out[72]:
    
In [73]:
    
plt.imshow(data,cmap=sns.blend_palette(hot,as_cmap=True))
    
    Out[73]:
    
In [74]:
    
plt.imshow(data,cmap=sns.blend_palette(hotcold,as_cmap=True))
    
    Out[74]:
    
In [75]:
    
plt.imshow(data,cmap=sns.blend_palette(rainbow,as_cmap=True))
    
    Out[75]:
    
In [75]: