Summary plots for the blog-entries

These plots are used here. See the respective notebooks for explanations etc.


In [1]:
import numpy as np
import matplotlib as mpl
from matplotlib import rc
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from adashof import circle, move_sn_y, fillgrid
rc('font', **{'size': 16, 'family': 'serif', 'serif': ['Computer Modern Roman']})
rc('text', usetex=True)
# Define colours (taken from http://colorbrewer2.org)
clr = ['#377eb8', '#e41a1c', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628']

In [2]:
etopo1name = 'data/basemap/etopo1_bedrock.asc'
topo_file = open(etopo1name, 'r')
ncols = int(topo_file.readline().split()[1])
nrows = int(topo_file.readline().split()[1])
xllcorner = float(topo_file.readline().split()[1])
yllcorner = float(topo_file.readline().split()[1])
cellsize = float(topo_file.readline().split()[1])
topo_file.close()
etopo = np.loadtxt(etopo1name, skiprows=5)
dres = 4
etopo[:nrows+1, :] = etopo[nrows+1::-1, :]
etopo = etopo[::dres, ::dres]
lons = np.arange(xllcorner, xllcorner+cellsize*ncols, cellsize)[::dres]
lats = np.arange(yllcorner, yllcorner+cellsize*nrows, cellsize)[::dres]
fig = plt.figure(figsize=(6, 2))
m = Basemap(width=800000, height=200000,
            resolution='l', projection='tmerc',
            lon_0=1, lat_0=58.5)
rlons, rlats = m(*np.meshgrid(lons,lats))
llevels = np.arange(-500,2001,10)
lcs = m.contourf(rlons, rlats, etopo, llevels, cmap=cm.terrain)
olevels = np.arange(-500,1,10)
cso = m.contourf(rlons, rlats, etopo, olevels, cmap=cm.ocean)
#plt.savefig('../content/images/blog/basemap_summary.png', pad_inches=.05, bbox_inches='tight', transparent=True)



In [3]:
x = np.arange(101)/100*2*np.pi
y = np.sin(x)
cxy = (np.arange(5)*np.pi/2, np.sin(np.arange(5)*np.pi/2))
fig1d = plt.figure(figsize=(6,1), frameon=False)
plt.gca().set_axis_off()
plt.plot(x, y, '-', c=clr[6], lw=2)
plt.axis([min(x), max(x), 1.2*min(y), 1.2*max(y)])
for i in range(5):
    circle((cxy[0][i], cxy[1][i]), .06, {'color':clr[i], 'clip_on': False})

#plt.savefig('../content/images/blog/circle_summary.svg', pad_inches=.1, bbox_inches='tight', transparent=True)



In [4]:
rc('text', color='red')
fig = plt.figure(figsize=(3,.6))
plt.subplots_adjust(wspace=1.5)
plt.subplot(121)  
plt.plot(np.arange(10)*.4, np.arange(10)*70e8)
plt.axis([-.2, .2, 5.5e10, 6.9e10])
plt.yticks([6e10])
plt.xticks([])

plt.subplot(122)  
plt.plot(np.arange(10)*.4, np.arange(10)*70e8)
locs = move_sn_y(offs=.7, side='left')
plt.axis([-.2, .2, 5.5e10, 6.9e10])
plt.xticks([])

#plt.savefig('../content/images/blog/move_sn_y_summary.svg', pad_inches=.1, dpi=300, bbox_inches='tight', transparent=True)
rc('text', color='black')



In [5]:
x = np.array([0, 3, 5, 6, 7, 10, 11, 12])
y = np.array([0, 1, 3, 4, 5])
val = np.random.rand(len(x)-1, len(y)-1)*(1.5)-.5
val[val<=0] = np.NaN
fig = plt.figure(figsize=(8, 2))
def create_figure(inp, y=y):
    sfig = plt.subplot(inp)
    ax = plt.gca()
    ax.set_axis_off()
    ax.axis('equal')
    ax.set_xlim([-.1, max(x)+.1])
create_figure(121)
rct = fillgrid(x, y, val, 'colour', lc='w', lw=1)
create_figure(122)
rct = fillgrid(x, y, val, 'alpha', unicol=clr[0], lc=clr[0], lw=2)

#plt.savefig('../content/images/blog/fillgrid_summary.png', pad_inches=0, bbox_inches='tight', transparent=True)