forked from justinbois/bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotting_round_one.py
38 lines (32 loc) · 1.16 KB
/
plotting_round_one.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
#Set maplotlib rc params.
rc = {'lines.linewidth' : 2, 'axes.labelsize' : 18,
'axes.titlesize' : 18}
sns.set(rc=rc)
#Load the food data
xa_high = np.loadtxt('data/xa_high_food.csv',comments='#')
xa_low = np.loadtxt('data/xa_low_food.csv',comments='#')
#Make the bin boundaries.
low_min = np.min(xa_low)
low_high = np.max(xa_low)
high_min = np.min(xa_high)
high_max = np.max(xa_high)
global_min = np.min([low_min, high_min])
global_max = np.max([low_high, high_max])
bins = np.arange(global_min-50, global_max+50, 50)
#Plot data as a histogram
_ = plt.hist((xa_low,xa_high), bins=bins)
plt.xlabel('Cross-sectional area (μm$^2$)')
plt.ylabel('count')
plt.show()
#Plot the data as two overlapping histograms
_ = plt.hist(xa_low, normed=True, bins=bins, histtype='stepfilled', alpha=0.5)
_ = plt.hist(xa_high, normed=True, bins=bins, histtype='stepfilled', alpha=0.5)
plt.xlabel('Cross-sectional area (μm$^2$)')
plt.ylabel('frequency')
plt.legend(('low concentration','high concentration'), loc='upper right')
plt.show()
#Save the figure.
plt.savefig('egg_area_histograms.svg', bbox_inches='tight')