In [4]:
##### HW 3, problem 2 #####
# Sean Lubner

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

# import the data
google = np.loadtxt('hw_3_data/google_data.txt', skiprows=1)
ny = np.loadtxt('hw_3_data/ny_temps.txt', skiprows=1)
yahoo = np.loadtxt('hw_3_data/yahoo_data.txt', skiprows=1)

In [ ]:
# Generate the initial plot (figure, axes, lines)
f1, ax1 = plt.subplots()         
f1.set_size_inches(11.2,8.56)
yahoo_line, = ax1.plot(yahoo[:,0], yahoo[:,1], c='purple', label='Yahoo! Stock Value') 
google_line, = ax1.plot(google[:,0], google[:,1], c='blue', label='Google Stock Value')  
ny_line, = ax1.plot(ny[:,0], ny[:,1], c='red', label='NY Mon. High Temp')  
ax1.set_title('Measured Thermal Conductivities: Water and \nAgar Gel', size=20, fontweight='bold')      
ax1.set_xlabel('Temperature, T ($^{\circ}$C)', size=18, fontweight='bold') 
ax1.set_ylabel('Thermal Conductivity, k (W/m-K)', size=18, fontweight='bold')

# Format ticks, axes & labels
ax1.axis([-30, 35, 0, 4])
ax1.set_yticks([0,1,2,3,4])
ax1.yaxis.tick_left() # remove ticks at right
ax1.xaxis.tick_bottom() # remove ticks at top
plt.setp(ax1.get_xticklabels(), fontsize=14, weight='bold')
plt.setp(ax1.get_yticklabels(), fontsize=14, weight='bold')
ax1.tick_params('both', width=2, which='major')


# Format the lines
plt.setp(agar_line, ls="none", marker='^', ms=11, mfc='lightgreen', mew=1.5, mec='green')
plt.setp(ice_line, ls="none", marker='s', ms=11, mfc='lightblue', mew=1.5, mec='blue')

# Render and format legend
l = ax1.legend([ice_line, agar_line, water_line], # control order of legend
               [ice_line.get_label(), agar_line.get_label(), water_line.get_label()], 
               bbox_to_anchor=(0.98,0.8),
               prop={'size':18}) # control location of legend
l.draw_frame(False) # no box

# Add in "a" label
plt.annotate("a", weight='bold', xy=(0.1, .9),  xycoords='axes fraction', size=42, va='center',
             bbox=dict(fc='white', ec='black', lw=2, pad=20))

plt.savefig('WaterAgarFigure_matplotlib.pdf') # Save the figure