@@ -13,6 +13,10 @@ class AlphaSelector(OutputDir):
1313 FIGURE_HEIGHT = 8
1414 plt .rcParams .update ({'font.size' : FIGURE_FONTSIZE })
1515
16+ plt .rcParams ["pdf.fonttype" ] = 42 # If saving as PDF too
17+ plt .rcParams ["font.family" ] = "Univers, DejaVu Sans" # Choose a font that supports embedding
18+
19+
1620 def __init__ (self ,
1721 prediction_dataset : PredictionDataset ,
1822 cop_class ,
@@ -78,9 +82,10 @@ def run_reports(self):
7882 print (f'Reports saved to { self .output_dir } ' )
7983
8084 def visualize (self ):
81- # MEAN SET SIZES GRAPH
82- plt .figure (figsize = (self .FIGURE_WIDTH ,
83- self .FIGURE_HEIGHT ))
85+ fig = plt .figure ()
86+ plt .tight_layout ()
87+ plt .rcParams .update ({'font.size' : 8 })
88+
8489 plt .tight_layout ()
8590
8691 data = pd .DataFrame ({
@@ -89,12 +94,13 @@ def visualize(self):
8994 })
9095
9196 sns .lineplot (data = data , x = 'Alpha' , y = 'Mean Set Size' )
92- plt .savefig (f'{ self .output_dir } /alpha_to_mean_set_size.png ' )
97+ plt .savefig (f'{ self .output_dir } /alpha_to_mean_set_size.pdf' , format = 'pdf ' )
9398
9499 # PERCENT EMPTY/SINGLETON SETS GRAPH
95100 # MEAN SET SIZES GRAPH
96- plt .figure (figsize = (self .FIGURE_WIDTH ,
97- self .FIGURE_HEIGHT ))
101+ fig = plt .figure ()
102+ plt .tight_layout ()
103+ plt .rcParams .update ({'font.size' : 6 })
98104 plt .tight_layout ()
99105
100106 # Labels
@@ -145,12 +151,14 @@ def visualize(self):
145151 plt .legend (loc = 'upper right' , title = legend_title )
146152
147153 # Save the plot to a file
148- plt .savefig (f'{ self .output_dir } /alpha_to_set_sizes.png' )
154+ fig .set_size_inches (4 , 3 )
155+ plt .tight_layout (w_pad = 0 )
156+ plt .savefig (f'{ self .output_dir } /alpha_to_set_sizes.pdf' , format = 'pdf' , pad_inches = 0 )
149157
150158 def visualize_lambdas (self ):
151- plt .figure (figsize = (self .FIGURE_WIDTH ,
152- self .FIGURE_HEIGHT ))
159+ fig = plt .figure ()
153160 plt .tight_layout ()
161+ plt .rcParams .update ({'font.size' : 6 })
154162
155163 # Only use reasonable alphas
156164 alphas = [0.05 , 0.1 , 0.15 , 0.2 , 0.3 , 0.4 ]
@@ -186,10 +194,12 @@ def visualize_lambdas(self):
186194
187195 plt .xlabel ('λ' )
188196 plt .ylabel ('Constraint function f(λ)' )
189- plt .title (f'FNR-controlling threshold { SYM_LAMHAT } ' )
197+ # plt.title(f'FNR-controlling threshold {SYM_LAMHAT}')
190198
191199 # Save the plot to a file
192- plt .savefig (f'{ self .output_dir } /lambdas.png' )
200+ fig .set_size_inches (4 , 3 )
201+ plt .tight_layout (w_pad = 0 )
202+ plt .savefig (f'{ self .output_dir } /lambdas.pdf' , format = 'pdf' )
193203
194204 def save_summary (self ):
195205 # Export the statistics to CSV
0 commit comments