@@ -1078,6 +1078,13 @@ def _set_color_source_vec(
10781078 table_name = table_name ,
10791079 )
10801080
1081+ # When both the element's own dataframe and the chosen table contain a
1082+ # column with this name, an explicit `table_name=` resolves the ambiguity —
1083+ # keep only the table origin and skip the multi-origin error below.
1084+ explicit_table_shadows_df = table_name is not None and any (o .origin == "df" for o in origins )
1085+ if explicit_table_shadows_df :
1086+ origins = [o for o in origins if o .origin != "df" ]
1087+
10811088 if len (origins ) > 1 :
10821089 raise ValueError (
10831090 f"Color key '{ value_to_plot } ' for element '{ element_name } ' was found in multiple locations: { origins } . "
@@ -1094,6 +1101,15 @@ def _set_color_source_vec(
10941101 )
10951102 if preloaded_color_data is not None :
10961103 color_source_vector = preloaded_color_data
1104+ elif explicit_table_shadows_df :
1105+ # Pass the table as `element` so upstream `get_values` skips the
1106+ # element-column lookup and avoids the multi-origin error.
1107+ color_source_vector = get_values (
1108+ value_key = value_to_plot ,
1109+ element = sdata [table_name ],
1110+ element_name = element_name ,
1111+ table_layer = table_layer ,
1112+ )[value_to_plot ]
10971113 else :
10981114 color_source_vector = get_values (
10991115 value_key = value_to_plot ,
@@ -3170,9 +3186,9 @@ def _validate_col_for_column_table(
31703186 if col_for_color is None :
31713187 return None , None
31723188
3173- if not labels and col_for_color in sdata [element_name ].columns :
3174- table_name = None
3175- elif table_name is not None :
3189+ if not labels and col_for_color in sdata [element_name ].columns and table_name is None :
3190+ return col_for_color , None
3191+ if table_name is not None :
31763192 tables = get_element_annotators (sdata , element_name )
31773193 if table_name not in tables :
31783194 logger .warning (f"Table '{ table_name } ' does not annotate element '{ element_name } '." )
0 commit comments