11#!/usr/bin/env python3
22import argparse
33import os
4+ import re
45from src .database_to_graph import *
56
67############################################################
@@ -29,19 +30,38 @@ def run_benchmark_plotter(input_arguments):
2930 graph_group .add_argument ('--ignore-non-optimal-planner' , action = 'store_const' , const = True , help = 'Do not plot non-optimal planner.' )
3031 graph_group .add_argument ('--ignore-planner' , action = 'store' , type = str , nargs = '+' , help = 'Exclude planners from graph (accepts multiple planner names)' )
3132 graph_group .add_argument ('--legend-separate-file' , action = 'store_const' , const = True , help = 'Print legend as separate file.' )
32- graph_group .add_argument ('--legend-below-figure' , action = 'store_const' ,
33- const = True , help = 'Print legend below graph.' )
34- graph_group .add_argument ('--legend-none' , action = 'store_const' ,
35- const = True , help = 'Do not print legend.' )
36- graph_group .add_argument ('--remove-ylabel' , action = 'store_const' ,
37- const = True , help = 'Do not print label on y-axis.' )
33+ graph_group .add_argument ('--legend-below-figure' , action = 'store_const' , const = True , help = 'Print legend below graph.' )
34+ graph_group .add_argument ('--legend-none' , action = 'store_const' , const = True , help = 'Do not print legend.' )
35+ graph_group .add_argument ('--remove-ylabel' , action = 'store_const' , const = True , help = 'Do not print label on y-axis.' )
3836 graph_group .add_argument ('--title-name' , action = 'store' , type = str , help = 'Set title name.' )
3937 graph_group .add_argument ('--no-title' , action = 'store_const' , const = True , help = 'Do not set a title for this graph' )
38+ graph_group .add_argument ('--planner-color' , type = str , action = 'append' , help = 'Specify custom colors for planners as PlannerName=(R,G,B,A), e.g., --planner-color Planner1=(0.7,0.1,0.7,1.0)' )
4039
4140 args = parser .parse_args (input_arguments )
4241 if args .quiet :
4342 args .verbose = 0
4443
44+ ############################################################
45+ ## Parse custom planner colors
46+ ############################################################
47+ planner_colors = {}
48+ if args .planner_color :
49+ for color_spec in args .planner_color :
50+ match = re .match (r'(\w+)=\((\d*\.?\d+),(\d*\.?\d+),(\d*\.?\d+),(\d*\.?\d+)\)' , color_spec )
51+ if match :
52+ planner_name = match .group (1 )
53+ rgba = tuple (float (match .group (i )) for i in range (2 , 6 ))
54+ if all (0 <= v <= 1 for v in rgba ):
55+ planner_colors [planner_name ] = rgba
56+ else :
57+ if args .verbose > 0 :
58+ print (f"Error: RGBA values for { planner_name } must be between 0 and 1." )
59+ return 1
60+ else :
61+ if args .verbose > 0 :
62+ print (f"Error: Invalid color format for { color_spec } . Expected PlannerName=(R,G,B,A)." )
63+ return 1
64+
4565 ############################################################
4666 ## Sanity checks
4767 ############################################################
@@ -64,9 +84,11 @@ def run_benchmark_plotter(input_arguments):
6484 print ("Create optimality graphs for {} files." .format (len (args .database_files )))
6585
6686 plot_config = make_config (args )
87+ plot_config ["planner_colors" ] = planner_colors
6788 plot_graph_from_databases (args .database_files , plot_config )
6889
6990 return 0
7091
7192if __name__ == '__main__' :
93+ import sys
7294 sys .exit (run_benchmark_plotter (sys .argv [1 :]))
0 commit comments