Commit 7d85258
committed
Keep plot_spacer invisible when a theme is applied via & or *
Compose.__and__/__mul__ apply themes to items via item += rhs, which
dispatches to ggplot.__iadd__ → theme.__radd__. For a complete theme
that takes the "replace" branch, overwriting the spacer's theme_void()
foundation so the spacer paints a panel.
Override __iadd__ on plot_spacer to merge only plot_background into the
existing theme_void(), and have __add__ delegate via deepcopy → __iadd__
so the merge logic lives in one place.
plot_spacer.__add__ used to silently swallow any non-PlotAddable rhs,
so spacer + plot was a no-op. Match ggplot.__add__'s contract: ggplot
or Compose on the right composes into a Wrap, just like plot + plot.
A theme still contributes only its plot_background fill into the
spacer's theme_void() foundation.
closes #10551 parent 537ecc3 commit 7d85258
4 files changed
Lines changed: 42 additions & 10 deletions
File tree
- plotnine/composition
- tests
- baseline_images/test_plot_composition
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
| |||
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
21 | 32 | | |
22 | 33 | | |
| |||
33 | 44 | | |
34 | 45 | | |
35 | 46 | | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
41 | 53 | | |
42 | | - | |
| 54 | + | |
43 | 55 | | |
44 | 56 | | |
45 | 57 | | |
46 | | - | |
47 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
48 | 62 | | |
49 | | - | |
50 | 63 | | |
51 | 64 | | |
52 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
53 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
0 commit comments