ebola example: moved all imports to the top of the file; fixed io import; seaborn import surround with try-catch
@@ -10,18 +10,23 @@ from treetime import TreeTime
import numpy as np
from scipy import optimize as sciopt
-if __name__ == '__main__':
-
- # load data and parse dates
import matplotlib.pyplot as plt
from matplotlib import cm
- import seaborn as sns
- sns.set_style('white')
+import datetime
from Bio import Phylo
+from treetime.utils import numeric_date
+try:
+ import seaborn as sns
+ sns.set_style('whitegrid')
+except:
+ print ("Seaborn not found. Default style will be used for the plots")
+
+
+if __name__ == '__main__':
+
+
plt.ion()
base_name = 'data/ebola'
- import datetime
- from treetime.utils import numeric_date
with open(base_name+'.csv') as date_file:
dates = {}
for line in date_file:
@@ -49,7 +54,7 @@ if __name__ == '__main__':
plt.legend(loc=2)
# rescale branch length to years and plot in axis 0
- from treetime.io import plot_vs_years
+ from treetime.treetime import plot_vs_years
fig, axs = plt.subplots(1,2, sharey=True, figsize=(12,8))
plot_vs_years(ebola, years=1, ax=axs[1], confidence=(0.05,0.95), label_func = lambda x:"")
axs[1].set_xlim(0, 2.5)
