@@ -89,7 +89,6 @@ def UpSetAltair(
8989 line_connection_size : int = 1 , # Reduced from 2
9090 horizontal_bar_size : int = 20 ,
9191 vertical_bar_label_size : int = 16 ,
92- vertical_bar_padding : int = 20 ,
9392 theme : Optional [str ] = None ,
9493) -> UpSetChart :
9594 """Generate interactive UpSet plots using Altair. [Lex et al., 2014]_
@@ -138,8 +137,6 @@ def UpSetAltair(
138137 Height of horizontal bars in pixels.
139138 vertical_bar_label_size : int, default 16
140139 Font size of vertical bar labels.
141- vertical_bar_padding : int, default 20
142- Padding between vertical bars.
143140 theme : str, optional
144141 Altair theme to use. If None, uses the current default theme.
145142
@@ -214,10 +211,10 @@ def UpSetAltair(
214211 vertical_bar_chart_height = height * height_ratio
215212 matrix_height = (height - vertical_bar_chart_height ) * 0.8 # Reduce height to tighten spacing
216213 matrix_width = width - horizontal_bar_chart_width
217- vertical_bar_size = min (
218- 30 ,
219- width / len (data ["intersection_id" ].unique ().tolist ()) - vertical_bar_padding ,
220- )
214+
215+ # Automatic padding
216+ num_intersections = max ( 1 , len (data ["intersection_id" ].unique ().tolist ()))
217+ vertical_bar_size = min ( 30 , ( matrix_width / num_intersections ) - 5 ) # 5 is good
221218
222219 # Setup styles
223220 main_color = "#3A3A3A"
@@ -232,9 +229,9 @@ def UpSetAltair(
232229 field = "count" if sort_by == "frequency" else "degree" , order = sort_order
233230 )
234231 tooltip = [
235- alt .Tooltip ("max( count) :Q" , title = "Cardinality" ),
232+ alt .Tooltip ("count:Q" , title = "Cardinality" ),
236233 alt .Tooltip ("degree:Q" , title = "Degree" ),
237- alt .Tooltip ("sets :N" , title = "Sets " ),
234+ # alt.Tooltip("sets_graph :N", title="Groups "), # Bugged. sets_graph is already available in preprocessing.py
238235 ]
239236
240237 # Create base chart
@@ -299,7 +296,7 @@ def UpSetAltair(
299296 horizontal_bar_axis ,
300297 horizontal_bar .properties (width = horizontal_bar_chart_width ),
301298 spacing = 0 , # Minimize spacing between components
302- ).resolve_scale (y = "shared" ),
299+ ).resolve_scale (x = "shared" , y = "shared" ), # X shared also
303300 spacing = 5 ,
304301 ).add_params (legend_selection )
305302
0 commit comments