diff options
author | Camil Staps | 2015-09-13 18:14:38 +0200 |
---|---|---|
committer | Camil Staps | 2015-09-13 18:40:07 +0200 |
commit | db2309142981324c5ff8917e9f0cc95b5529dfe5 (patch) | |
tree | 7ad88a1dbfe125ec5f131868284423d0d380c80b /Assignment 1/ex12.py | |
parent | Initial commit (diff) |
Assignment 1, 1.1 & 1.2 start
Diffstat (limited to 'Assignment 1/ex12.py')
-rw-r--r-- | Assignment 1/ex12.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Assignment 1/ex12.py b/Assignment 1/ex12.py new file mode 100644 index 0000000..3db49e1 --- /dev/null +++ b/Assignment 1/ex12.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +""" +Created on Fri Sep 11 13:12:03 2015 + +@author: camilstaps +""" + +from __future__ import print_function +import xlrd +import numpy as np +import matplotlib.lines as pltlines +import matplotlib.patches as pltpatches +import matplotlib.pyplot as plt + +# 1.2.1 a + +xls = xlrd.open_workbook(filename='Data/nanonose.xls') +xls = xls.sheet_by_index(0) + +fst_col, fst_row = 3, 2 +data = np.asmatrix([xls.col_values(i)[fst_row:] + for i in range(fst_col,fst_col + 8)]) + +# 1.2.1 b +colors = {'Water': '#61d4fa', + 'Ethanol': '#ff3333', + 'Acetone': '#549900', + 'Heptane': '#d9910d', + 'Pentanol': '#990096'} +graph_colors = [colors[r] for r in xls.col_values(0)[fst_row:]] + +xs = xls.col_values(1)[fst_row:] + +fig = plt.figure(figsize=(12,6)) +ax = plt.gca() +ax.set_xscale('log') +ax.set_yscale('symlog') +plt.xlim([80,10 ** 5]) +plt.ylim([-1, 500]) + +ax.scatter(xs, data.tolist()[0], s=60, c=graph_colors, alpha=0.4, marker='s') +ax.scatter(xs, data.tolist()[1], s=60, c=graph_colors, alpha=0.4, marker='o') + +line_a = pltlines.Line2D([], [], ls=' ', marker='s', label='A', c='w') +line_b = pltlines.Line2D([], [], ls=' ', marker='o', label='B', c='w') +handles = [pltpatches.Patch(label=k, color=v) for k, v in colors.iteritems()] + [line_a, line_b] +ax.legend(handles=handles, numpoints=1, loc=2) + +plt.show() |