5
5
import matplotlib
6
6
7
7
if platform != "win32" :
8
- gui_env = ['TKAgg ' , 'GTKAgg' , 'Qt4Agg' , 'WXAgg ' ]
8
+ gui_env = ['Qt5Agg ' , 'TkAgg ' ]
9
9
for gui in gui_env :
10
10
try :
11
11
matplotlib .use (gui , warn = False , force = True )
12
- from matplotlib import pyplot as plt
13
12
break
14
13
except :
15
14
continue
16
- else :
17
- import matplotlib .pyplot as plt
18
15
16
+ import matplotlib .pyplot as plt
19
17
from matplotlib import gridspec
20
18
import seaborn as sns
21
19
@@ -31,14 +29,16 @@ def report(df, column_ppm_error, column_adducts, fn_pdf):
31
29
ax_count = plt .subplot (gs [3 ])
32
30
#ax = plt.subplot(gs[1])
33
31
34
- sns .boxplot (df [column_ppm_error ], ax = ax_box )
35
- sns .distplot (df [column_ppm_error ], ax = ax_hist )
32
+ ppm_errors = df [column_ppm_error ].dropna ()
36
33
37
- std = df [column_ppm_error ].std ()
38
- mean = df [column_ppm_error ].mean ()
39
- median = df [column_ppm_error ].median ()
40
- Q1 = df [column_ppm_error ].quantile (0.25 )
41
- Q3 = df [column_ppm_error ].quantile (0.75 )
34
+ sns .boxplot (ppm_errors , ax = ax_box )
35
+ sns .distplot (ppm_errors , ax = ax_hist )
36
+
37
+ std = ppm_errors .std ()
38
+ mean = ppm_errors .mean ()
39
+ median = ppm_errors .median ()
40
+ Q1 = ppm_errors .quantile (0.25 )
41
+ Q3 = ppm_errors .quantile (0.75 )
42
42
43
43
# Remove x axis name for the boxplot
44
44
ax_box .set (xlabel = "" )
@@ -49,11 +49,10 @@ def report(df, column_ppm_error, column_adducts, fn_pdf):
49
49
ax_hist .set (xlabel = "ppm error" )
50
50
51
51
sns .set (style = "whitegrid" )
52
- sns .countplot (x = column_adducts , data = df , ax = ax_count )
52
+ sns .countplot (df [ column_adducts ]. dropna () , ax = ax_count )
53
53
54
54
plt .setp (ax_box .get_xticklabels (), visible = False )
55
55
56
56
fig .suptitle ('Summary - BEAMS' , fontsize = 20 )
57
57
fig .set_size_inches (11.69 , 8.27 )
58
58
fig .savefig (fn_pdf , format = "pdf" )
59
-
0 commit comments