@@ -140,6 +140,12 @@ def get_errors(point):
140140 [point ["cost" ][2 ] - point ["cost" ][0 ]]])
141141 return time_errors , cost_errors
142142
143+ def init_planner_colors (data ):
144+ planner_data = data ["planners" ]
145+ planners = list (planner_data .keys ())
146+ planners .sort ()
147+ for planner in planners :
148+ color = get_diverse_color (planner )
143149
144150def plot_success (ax , data ):
145151
@@ -154,9 +160,10 @@ def plot_success(ax, data):
154160 ax .set_xlim (min_time , max_time )
155161 ax .set_ylim (0.0 , 100.0 )
156162
163+ init_planner_colors (data )
164+
157165 planner_data = data ["planners" ]
158166 for planner in planner_data :
159- #color=get_color(data, planner)
160167 color = get_diverse_color (planner )
161168 success_over_time = planner_data [planner ]["success" ]
162169 ax .plot (times , success_over_time , color = color ,
@@ -212,48 +219,47 @@ def json_to_graph(json_filepath, pdf_filepath, config):
212219 with open (json_filepath , 'r' ) as jsonfile :
213220 data = json .load (jsonfile )
214221
215- fig , axs = plt .subplots (2 , 1 , sharex = 'col' , figsize = (16 ,10 ))
216-
217- plot_success (axs [0 ], data )
218- plot_optimization (axs [1 ], data , config )
222+ if config ["only_success_graph" ]:
223+ fig , axs = plt .subplots (1 , 1 , figsize = (16 ,10 ))
224+ plot_success (axs , data )
225+ ax_success = axs
226+ else :
227+ fig , axs = plt .subplots (2 , 1 , sharex = 'col' , figsize = (16 ,10 ))
228+ ax_success = axs [0 ]
229+ ax_cost = axs [1 ]
230+ plot_success (ax_success , data )
231+ plot_optimization (ax_cost , data , config )
219232
220233 fontsize = data ["info" ]["fontsize" ]
221234 label_fontsize = data ["info" ]["label_fontsize" ]
222235 experiment_name = get_experiment_label (data ["info" ]["experiment" ])
223236
224237 if 'title_name' in config :
225- axs [ 0 ] .set_title (config ['title_name' ], fontsize = fontsize )
238+ ax_success .set_title (config ['title_name' ], fontsize = fontsize )
226239 else :
227- axs [ 0 ] .set_title (experiment_name , fontsize = fontsize )
240+ ax_success .set_title (experiment_name , fontsize = fontsize )
228241
229242 legend_title_name = 'Planner'
230243 if not config ["legend_none" ]:
231244 if config ["legend_separate_file" ]:
232245 figl , axl = plt .subplots ()
233- label_params = axs [ 0 ] .get_legend_handles_labels ()
246+ label_params = ax_success .get_legend_handles_labels ()
234247 legend = axl .legend (* label_params , loc = "center" , frameon = True , ncol = 4 , fontsize = fontsize )
235248 for obj in legend .legendHandles :
236249 obj .set_linewidth (data ["info" ]["legend_linewidth" ])
237250 axl .axis ('off' )
238251 legend_filepath = change_filename_extension (json_filepath , '_legend.pdf' )
239252 figl .savefig (legend_filepath , bbox_extra_artists = (legend ,), bbox_inches = 'tight' )
240253 plt .close (figl )
241-
242- elif config ['legend_below_figure' ]:
243- label_params = axs [0 ].get_legend_handles_labels ()
244- legend = axs [1 ].legend (* label_params , loc = 'upper center' , bbox_to_anchor = (0.5 , - 0.3 ),
245- fancybox = True , ncol = 4 , fontsize = fontsize )
246- for obj in legend .legendHandles :
247- obj .set_linewidth (data ["info" ]["legend_linewidth" ])
248- plt .setp (legend .get_title (),fontsize = label_fontsize )
249254 else :
250- legend = axs [ 0 ] .legend (loc = 'upper left' , title = legend_title_name , fontsize = label_fontsize )
255+ legend = ax_success .legend (loc = 'upper left' , title = legend_title_name , fontsize = label_fontsize )
251256 for obj in legend .legendHandles :
252257 obj .set_linewidth (data ["info" ]["legend_linewidth" ])
253258 plt .setp (legend .get_title (),fontsize = label_fontsize )
254259
255- axs [0 ].tick_params (labelsize = label_fontsize )
256- axs [1 ].tick_params (labelsize = label_fontsize )
260+ ax_success .tick_params (labelsize = label_fontsize )
261+ if not config ["only_success_graph" ]:
262+ ax_cost .tick_params (labelsize = label_fontsize )
257263
258264 fig = plt .gcf ()
259265 if config ['legend_separate_file' ] or config ['legend_none' ]:
@@ -282,6 +288,8 @@ def plot_graph_from_databases(database_filepaths, config):
282288 data ["info" ]['fontsize' ] = config ['fontsize' ]
283289 if config ['label_fontsize' ] > 0 :
284290 data ["info" ]['label_fontsize' ] = config ['label_fontsize' ]
291+ if config ['verbosity' ] > 0 :
292+ data ["info" ]['verbosity' ] = config ['verbosity' ]
285293
286294 experiment_names = []
287295 experiment_times = []
0 commit comments