Skip to content

Commit 9e29c73

Browse files
edmundmillerclaude
andcommitted
fix(vertical-upset): improve visual layout and prevent component overlap
- Increase height_ratio from 0.4 to 0.6 to match horizontal upset plot - Reduce set_bar_size from 30 to 20 pixels for consistent styling - Add Y-axis scale padding (0.1) and enable nice scaling for set bars - Separate set labels from bars into distinct components to prevent overlap - Add 5px spacing between vconcat components for better visual separation - Update snapshot tests to reflect layout improvements These changes ensure vertical upset plots follow the same visual style as horizontal plots while fixing overlapping elements in the set label area. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b3e658f commit 9e29c73

3 files changed

Lines changed: 303 additions & 287 deletions

File tree

altair_upset/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def create_vertical_set_bars(
178178
offset=0,
179179
titlePadding=5,
180180
),
181-
scale=alt.Scale(zero=True, padding=0, nice=False),
181+
scale=alt.Scale(zero=True, padding=0.1, nice=True),
182182
title="Set Size",
183183
),
184184
)

altair_upset/upset.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def UpSetVertical(
436436
sort_order: str = "ascending",
437437
width: int = 1200,
438438
height: int = 700,
439-
height_ratio: float = 0.4,
439+
height_ratio: float = 0.6,
440440
color_range: List[str] = [
441441
"#55A8DB",
442442
"#3070B5",
@@ -450,7 +450,7 @@ def UpSetVertical(
450450
glyph_size: int = 100,
451451
set_label_bg_size: int = 500,
452452
line_connection_size: int = 1,
453-
set_bar_size: int = 30,
453+
set_bar_size: int = 20,
454454
cardinality_bar_width: Optional[int] = None,
455455
cardinality_bar_size: int = 20,
456456
cardinality_bar_label_size: int = 16,
@@ -480,7 +480,7 @@ def UpSetVertical(
480480
Total width of the plot in pixels.
481481
height : int, default 700
482482
Total height of the plot in pixels.
483-
height_ratio : float, default 0.4
483+
height_ratio : float, default 0.6
484484
Ratio of set bar height to total height.
485485
color_range : list of str
486486
List of colors for the sets.
@@ -494,7 +494,7 @@ def UpSetVertical(
494494
Size of the set label background circles.
495495
line_connection_size : int, default 1
496496
Thickness of connecting lines.
497-
set_bar_size : int, default 30
497+
set_bar_size : int, default 20
498498
Width of set bars in pixels.
499499
theme : str, optional
500500
Altair theme to use.
@@ -602,9 +602,12 @@ def UpSetVertical(
602602
main_color,
603603
)
604604

605-
set_bar_chart = (set_label_bg + set_label + set_bar).properties(
606-
width=matrix_width, height=set_bar_height
607-
)
605+
# Separate labels from bars to prevent overlap
606+
set_label_axis = (
607+
(set_label_bg + set_label) if is_show_set_label_bg else set_label
608+
).properties(width=matrix_width, height=40)
609+
610+
set_bar_only = set_bar.properties(width=matrix_width, height=set_bar_height - 40)
608611

609612
circle_bg, rect_bg, circle, line_connection = create_vertical_matrix(
610613
base,
@@ -653,13 +656,17 @@ def UpSetVertical(
653656
# Combine components vertically with cardinality bars
654657
upsetaltair = (
655658
alt.vconcat(
656-
alt.hconcat(set_bar_chart, spacer, spacing=0),
659+
alt.hconcat(
660+
alt.vconcat(set_bar_only, set_label_axis, spacing=0),
661+
spacer,
662+
spacing=0,
663+
),
657664
alt.hconcat(
658665
matrix_view,
659666
cardinality_bar_chart,
660667
spacing=0,
661668
).resolve_scale(y="shared"),
662-
spacing=0,
669+
spacing=5,
663670
)
664671
.resolve_scale(x="shared")
665672
.add_params(legend_selection)

0 commit comments

Comments
 (0)