@@ -206,6 +206,23 @@ def poplulate_plot_args(plot_args_p):
206206 nargs = '+' ,
207207 required = False ,
208208 help = "<prop1> <prop2> names of properties where branches will be colored based on different values." )
209+ group .add_argument ('--textbranch-layout' ,
210+ nargs = '+' ,
211+ required = False ,
212+ help = "<prop1> <prop2> names of properties where values will be displayed on the branch in text." )
213+ group .add_argument ('--circlebranch-layout' ,
214+ nargs = '+' ,
215+ required = False ,
216+ help = "<prop1> <prop2> names of properties where values will be displayed on the branch in the shape of cricle." )
217+ group .add_argument ('--squarebranch-layout' ,
218+ nargs = '+' ,
219+ required = False ,
220+ help = "<prop1> <prop2> names of properties where values will be displayed on the branch in the shape of square." )
221+ group .add_argument ('--trianglebranch-layout' ,
222+ nargs = '+' ,
223+ required = False ,
224+ help = "<prop1> <prop2> names of properties where values will be displayed on the branch in the shape of triangle." )
225+
209226 group .add_argument ('--label-layout' ,
210227 nargs = '+' ,
211228 required = False ,
@@ -537,6 +554,42 @@ def run(args):
537554 visualized_props .append (prop )
538555 visualized_props .append (utils .add_suffix (prop , internal_num_rep ))
539556
557+ if layout == 'textbranch-layout' :
558+ textbranch_layouts , level , color_dict = get_textbranch_layouts (tree , args .textbranch_layout ,
559+ level , column_width = args .column_width , prop2type = prop2type ,
560+ padding_x = args .padding_x , padding_y = args .padding_y , color_config = color_config )
561+ layouts .extend (textbranch_layouts )
562+ for prop in args .textbranch_layout :
563+ visualized_props .append (prop )
564+
565+ if layout == 'circlebranch-layout' :
566+ circlebranch_layouts , level , color_dict = get_circlebranch_layouts (tree , args .circlebranch_layout ,
567+ level , prop2type = prop2type , padding_x = args .padding_x , padding_y = args .padding_y , color_config = color_config )
568+ layouts .extend (circlebranch_layouts )
569+ for prop in args .circlebranch_layout :
570+ visualized_props .append (prop )
571+
572+ if layout == 'circlebranch-layout' :
573+ circlebranch_layouts , level , color_dict = get_circlebranch_layouts (tree , args .circlebranch_layout ,
574+ level , prop2type = prop2type , padding_x = args .padding_x , padding_y = args .padding_y , color_config = color_config )
575+ layouts .extend (circlebranch_layouts )
576+ for prop in args .circlebranch_layout :
577+ visualized_props .append (prop )
578+
579+ if layout == 'squarebranch-layout' :
580+ squarebranch_layouts , level , color_dict = get_squarebranch_layouts (tree , args .squarebranch_layout ,
581+ level , prop2type = prop2type , padding_x = args .padding_x , padding_y = args .padding_y , color_config = color_config )
582+ layouts .extend (squarebranch_layouts )
583+ for prop in args .squarebranch_layout :
584+ visualized_props .append (prop )
585+
586+ if layout == 'trianglebranch-layout' :
587+ trianglebranch_layouts , level , color_dict = get_trianglebranch_layouts (tree , args .trianglebranch_layout ,
588+ level , prop2type = prop2type , padding_x = args .padding_x , padding_y = args .padding_y , color_config = color_config )
589+ layouts .extend (trianglebranch_layouts )
590+ for prop in args .trianglebranch_layout :
591+ visualized_props .append (prop )
592+
540593 if layout == 'bubble-layout' :
541594 categorical_props = [prop for prop in args .bubble_layout if prop2type .get (prop ) in [str , list , bool , None ]]
542595 if categorical_props :
@@ -1203,6 +1256,133 @@ def get_colorbranch_layouts(tree, props, level, prop2type, column_width=70, padd
12031256 level += 1
12041257 return layouts , level , prop_color_dict
12051258
1259+ def get_textbranch_layouts (tree , props , level , prop2type , column_width = 70 , padding_x = 1 , padding_y = 0 , color_config = None ):
1260+ prop_color_dict = {}
1261+ layouts = []
1262+ for prop in props :
1263+ color_dict = {}
1264+ text_color = paired_color [level ]
1265+ if color_config and color_config .get (prop ):
1266+ if color_config .get (prop ).get ('value2color' ):
1267+ color_dict = color_config .get (prop ).get ('value2color' )
1268+
1269+ layout = text_layouts .LayoutTextbranch (name = 'TextBranch_' + prop ,
1270+ column = level , text_color = text_color , color_dict = color_dict , prop = prop ,
1271+ width = column_width , padding_x = padding_x , padding_y = padding_y )
1272+ layouts .append (layout )
1273+ level += 1
1274+
1275+ return layouts , level , prop_color_dict
1276+
1277+ def get_widthbranch_layouts (tree , props , level , prop2type , padding_x = 1 , padding_y = 0 , color_config = None ):
1278+ return
1279+
1280+ def get_circlebranch_layouts (tree , props , level , prop2type , padding_x = 1 , padding_y = 0 , color_config = None ):
1281+ prop_color_dict = {}
1282+ layouts = []
1283+ symbol = 'circle'
1284+ symbol_size = 5
1285+ max_radius = 1
1286+ fgopacity = 0.8
1287+
1288+ for prop in props :
1289+ color_dict = {} # key = value, value = color id
1290+ symbol_color = paired_color [level ]
1291+
1292+ if color_config and color_config .get (prop ):
1293+ if color_config .get (prop ).get ('value2color' ):
1294+ color_dict = color_config .get (prop ).get ('value2color' )
1295+ else :
1296+ if prop2type and prop2type .get (prop ) == list :
1297+ leaf_values = list (map (list ,set (map (tuple ,utils .tree_prop_array (tree , prop )))))
1298+ prop_values = [val for sublist in leaf_values for val in sublist ]
1299+ else :
1300+ prop_values = sorted (list (set (utils .tree_prop_array (tree , prop ))))
1301+
1302+ # normal text prop
1303+ color_dict = utils .assign_color_to_values (prop_values , paired_color )
1304+
1305+ layout = text_layouts .LayoutSymbolbranch (f'{ symbol } Branch_{ prop } ' , prop = prop ,
1306+ column = level , symbol = symbol , symbol_color = symbol_color , color_dict = color_dict ,
1307+ max_radius = max_radius , symbol_size = symbol_size ,
1308+ padding_x = padding_x , padding_y = padding_y , fgopacity = fgopacity ,
1309+ scale = True , legend = True , active = True
1310+ )
1311+ layouts .append (layout )
1312+ level += 1
1313+
1314+ return layouts , level , prop_color_dict
1315+
1316+ def get_squarebranch_layouts (tree , props , level , prop2type , padding_x = 1 , padding_y = 0 , color_config = None ):
1317+ prop_color_dict = {}
1318+ layouts = []
1319+ symbol = 'square'
1320+ symbol_size = 5
1321+ max_radius = 1
1322+ fgopacity = 0.8
1323+
1324+ for prop in props :
1325+ color_dict = {} # key = value, value = color id
1326+ symbol_color = paired_color [level ]
1327+
1328+ if color_config and color_config .get (prop ):
1329+ if color_config .get (prop ).get ('value2color' ):
1330+ color_dict = color_config .get (prop ).get ('value2color' )
1331+ else :
1332+ if prop2type and prop2type .get (prop ) == list :
1333+ leaf_values = list (map (list ,set (map (tuple ,utils .tree_prop_array (tree , prop )))))
1334+ prop_values = [val for sublist in leaf_values for val in sublist ]
1335+ else :
1336+ prop_values = sorted (list (set (utils .tree_prop_array (tree , prop ))))
1337+
1338+ # normal text prop
1339+ color_dict = utils .assign_color_to_values (prop_values , paired_color )
1340+
1341+ layout = text_layouts .LayoutSymbolbranch (f'{ symbol } Branch_{ prop } ' , prop = prop ,
1342+ column = level , symbol = symbol , symbol_color = symbol_color , color_dict = color_dict ,
1343+ max_radius = max_radius , symbol_size = symbol_size ,
1344+ padding_x = padding_x , padding_y = padding_y , fgopacity = fgopacity ,
1345+ scale = True , legend = True , active = True
1346+ )
1347+ layouts .append (layout )
1348+ level += 1
1349+ return layouts , level , prop_color_dict
1350+
1351+ def get_trianglebranch_layouts (tree , props , level , prop2type , padding_x = 1 , padding_y = 0 , color_config = None ):
1352+ prop_color_dict = {}
1353+ layouts = []
1354+ symbol = 'triangle'
1355+ symbol_size = 5
1356+ max_radius = 1
1357+ fgopacity = 0.8
1358+
1359+ for prop in props :
1360+ color_dict = {} # key = value, value = color id
1361+ symbol_color = paired_color [level ]
1362+
1363+ if color_config and color_config .get (prop ):
1364+ if color_config .get (prop ).get ('value2color' ):
1365+ color_dict = color_config .get (prop ).get ('value2color' )
1366+ else :
1367+ if prop2type and prop2type .get (prop ) == list :
1368+ leaf_values = list (map (list ,set (map (tuple ,utils .tree_prop_array (tree , prop )))))
1369+ prop_values = [val for sublist in leaf_values for val in sublist ]
1370+ else :
1371+ prop_values = sorted (list (set (utils .tree_prop_array (tree , prop ))))
1372+
1373+ # normal text prop
1374+ color_dict = utils .assign_color_to_values (prop_values , paired_color )
1375+
1376+ layout = text_layouts .LayoutSymbolbranch (f'{ symbol } Branch_{ prop } ' , prop = prop ,
1377+ column = level , symbol = symbol , symbol_color = symbol_color , color_dict = color_dict ,
1378+ max_radius = max_radius , symbol_size = symbol_size ,
1379+ padding_x = padding_x , padding_y = padding_y , fgopacity = fgopacity ,
1380+ scale = True , legend = True , active = True
1381+ )
1382+ layouts .append (layout )
1383+ level += 1
1384+ return layouts , level , prop_color_dict
1385+
12061386def get_rectangle_layouts (tree , props , level , prop2type , column_width = 70 , padding_x = 1 , padding_y = 0 , color_config = None , precomputed_props = {}):
12071387 prop_color_dict = {}
12081388 layouts = []
0 commit comments