1
1
""" Main file of the package """
2
- import numpy as np
2
+ import numpy as np , matplotlib as mpl
3
3
from matplotlib import pyplot as plt
4
- import matplotlib as mpl
4
+ from matplotlib import offsetbox
5
5
from scipy .stats import norm
6
6
from scipy .optimize import minimize
7
7
import warnings
@@ -110,7 +110,7 @@ def get_crossings(self, alpha = 0.05, outfile = None, **kwargs):
110
110
:param alpha: 1 - alpha = confidence level for confidence bands
111
111
:param outfile: path to output figure displaying algorithm
112
112
"""
113
- plt_set = {'fontsize' : 18 , 'legend_fontsize' : 20 , 'labelsize' : 28 , 'linecolor' : '#f9665e' , 'bandcolor' : '#a8d9ed' , 'linewidth' : 2 , 'dpi' : 100 }
113
+ plt_set = {'fontsize' : 19 , 'legend_fontsize' : 20 , 'labelsize' : 28 , 'linecolor' : '#f9665e' , 'bandcolor' : '#a8d9ed' , 'linewidth' : 2 , 'dpi' : 100 }
114
114
for key , value in kwargs .items ():
115
115
plt_set [key ] = value
116
116
@@ -184,7 +184,7 @@ def pp_plot(self, confidence_band = True, alpha = 0.05, outfile = None, **kwargs
184
184
:param alpha: the upper bound for the probability that an ecdf plot of the normal
185
185
approximation falls outside the shaded region
186
186
"""
187
- plt_set = {'fontsize' : 18 , 'legend_fontsize' : 20 , 'labelsize' : 28 , 'pointsize' : 7 , 'pointcolor' : '#f9665e' , 'bandcolor' : '#a8d9ed' , 'dpi' : 100 }
187
+ plt_set = {'fontsize' : 19 , 'legend_fontsize' : 20 , 'labelsize' : 28 , 'pointsize' : 7 , 'pointcolor' : '#f9665e' , 'bandcolor' : '#a8d9ed' , 'dpi' : 100 }
188
188
for key , value in kwargs .items ():
189
189
plt_set [key ] = value
190
190
@@ -203,26 +203,26 @@ def pp_plot(self, confidence_band = True, alpha = 0.05, outfile = None, **kwargs
203
203
('Num. replicates = %d' % num_replicates ,
204
204
'Pos. distance = %.3f' % self .pos_dist ,
205
205
'Neg. distance = %.3f' % self .neg_dist ))
206
- props = dict (boxstyle = 'round, pad = 0.75, rounding_size = 0.3' , facecolor = 'white' , alpha = 0.86 )
206
+ props = dict (boxstyle = 'round, pad = 0.75, rounding_size = 0.3' , facecolor = 'white' , alpha = 0.8 )
207
207
208
208
plt .rc ('font' , size = plt_set ['fontsize' ])
209
209
plt .rc ('legend' , fontsize = plt_set ['legend_fontsize' ])
210
210
plt .rc ('axes' , labelsize = plt_set ['labelsize' ])
211
211
fig , ax = plt .subplots (figsize = (10 , 10 ))
212
+ ax .set_ylim (0 , 1 )
213
+ ax .set_xlim (0 , 1 )
212
214
213
215
if confidence_band == True :
214
216
ax .fill_between (dkw_xgrid , dkw_lbound , dkw_ubound , color = plt_set ['bandcolor' ], label = 'Confidence band' , alpha = 0.35 )
215
217
ax .scatter (replicates_eval_normcdf , replicate_ecdf , s = plt_set ['pointsize' ],
216
- c = plt_set ['pointcolor' ], label = 'Bootstrap replicates ' )
218
+ c = plt_set ['pointcolor' ], label = 'Bootstrap reps. ' )
217
219
ax .set_xlabel ("CDF of normal distribution" )
218
220
ax .set_ylabel ("CDF of bootstrap distribution" )
219
221
ax .legend (edgecolor = 'k' , loc = 'upper left' )
220
222
ax .axline ((0 , 0 ), (1 , 1 ), color = "black" , linestyle = (0 , (5 , 5 )))
221
- ax .text (0.52 , 0.06 , plot_data , fontsize = plt_set ['legend_fontsize' ], \
222
- verticalalignment = 'bottom' , horizontalalignment = 'left' , bbox = props )
223
- ax .set_ylim (0 , 1 )
224
- ax .set_xlim (0 , 1 )
225
-
223
+ offbox = offsetbox .AnchoredText (plot_data , loc = "lower right" , borderpad = 1.25 , pad = 0 )
224
+ offbox .patch .set (** props )
225
+ ax .add_artist (offbox )
226
226
if not outfile == None :
227
227
fig .savefig (outfile , transparent = True , dpi = plt_set ['dpi' ])
228
228
return fig
0 commit comments