plotnine 0.14.5__py3-none-any.whl → 0.15.0a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plotnine/__init__.py +31 -37
- plotnine/_mpl/gridspec.py +265 -0
- plotnine/_mpl/layout_manager/__init__.py +6 -0
- plotnine/_mpl/layout_manager/_engine.py +87 -0
- plotnine/_mpl/layout_manager/_layout_items.py +957 -0
- plotnine/_mpl/layout_manager/_layout_tree.py +905 -0
- plotnine/_mpl/layout_manager/_spaces.py +1154 -0
- plotnine/_mpl/patches.py +70 -34
- plotnine/_mpl/text.py +159 -37
- plotnine/_mpl/utils.py +78 -10
- plotnine/_utils/__init__.py +35 -9
- plotnine/_utils/dev.py +45 -27
- plotnine/_utils/yippie.py +115 -0
- plotnine/animation.py +1 -1
- plotnine/coords/coord.py +3 -3
- plotnine/coords/coord_trans.py +1 -1
- plotnine/data/__init__.py +43 -8
- plotnine/data/anscombe-quartet.csv +45 -0
- plotnine/doctools.py +2 -2
- plotnine/facets/facet.py +34 -43
- plotnine/facets/facet_grid.py +14 -6
- plotnine/facets/facet_wrap.py +3 -5
- plotnine/facets/strips.py +20 -33
- plotnine/geoms/annotate.py +3 -3
- plotnine/geoms/annotation_logticks.py +2 -0
- plotnine/geoms/annotation_stripes.py +2 -0
- plotnine/geoms/geom.py +3 -3
- plotnine/geoms/geom_bar.py +10 -2
- plotnine/geoms/geom_col.py +6 -0
- plotnine/geoms/geom_crossbar.py +2 -3
- plotnine/geoms/geom_path.py +2 -2
- plotnine/geoms/geom_violin.py +24 -7
- plotnine/ggplot.py +95 -66
- plotnine/guides/guide.py +19 -20
- plotnine/guides/guide_colorbar.py +6 -6
- plotnine/guides/guide_legend.py +15 -16
- plotnine/guides/guides.py +8 -8
- plotnine/helpers.py +49 -0
- plotnine/iapi.py +33 -7
- plotnine/labels.py +8 -3
- plotnine/layer.py +4 -4
- plotnine/mapping/_env.py +2 -2
- plotnine/mapping/_eval_environment.py +85 -0
- plotnine/mapping/aes.py +14 -30
- plotnine/mapping/evaluation.py +7 -65
- plotnine/options.py +14 -7
- plotnine/plot_composition/__init__.py +10 -0
- plotnine/plot_composition/_compose.py +462 -0
- plotnine/plot_composition/_plotspec.py +50 -0
- plotnine/plot_composition/_spacer.py +32 -0
- plotnine/positions/position_dodge.py +1 -1
- plotnine/positions/position_dodge2.py +1 -1
- plotnine/positions/position_stack.py +1 -2
- plotnine/qplot.py +1 -2
- plotnine/scales/__init__.py +0 -6
- plotnine/scales/limits.py +7 -7
- plotnine/scales/scale.py +4 -4
- plotnine/scales/scale_continuous.py +2 -1
- plotnine/scales/scale_identity.py +10 -2
- plotnine/scales/scale_manual.py +6 -2
- plotnine/stats/binning.py +5 -2
- plotnine/stats/smoothers.py +3 -5
- plotnine/stats/stat.py +3 -3
- plotnine/stats/stat_bindot.py +1 -3
- plotnine/stats/stat_density.py +2 -2
- plotnine/stats/stat_qq_line.py +1 -1
- plotnine/stats/stat_sina.py +34 -1
- plotnine/themes/elements/__init__.py +3 -0
- plotnine/themes/elements/element_text.py +35 -24
- plotnine/themes/elements/margin.py +137 -61
- plotnine/themes/targets.py +3 -1
- plotnine/themes/theme.py +21 -7
- plotnine/themes/theme_538.py +0 -1
- plotnine/themes/theme_bw.py +0 -1
- plotnine/themes/theme_dark.py +0 -1
- plotnine/themes/theme_gray.py +32 -34
- plotnine/themes/theme_light.py +1 -1
- plotnine/themes/theme_matplotlib.py +28 -31
- plotnine/themes/theme_seaborn.py +36 -36
- plotnine/themes/theme_void.py +25 -27
- plotnine/themes/theme_xkcd.py +0 -1
- plotnine/themes/themeable.py +369 -169
- plotnine/typing.py +3 -3
- plotnine/watermark.py +3 -3
- {plotnine-0.14.5.dist-info → plotnine-0.15.0a2.dist-info}/METADATA +8 -5
- {plotnine-0.14.5.dist-info → plotnine-0.15.0a2.dist-info}/RECORD +89 -78
- {plotnine-0.14.5.dist-info → plotnine-0.15.0a2.dist-info}/WHEEL +1 -1
- plotnine/_mpl/_plot_side_space.py +0 -888
- plotnine/_mpl/_plotnine_tight_layout.py +0 -293
- plotnine/_mpl/layout_engine.py +0 -110
- {plotnine-0.14.5.dist-info → plotnine-0.15.0a2.dist-info/licenses}/LICENSE +0 -0
- {plotnine-0.14.5.dist-info → plotnine-0.15.0a2.dist-info}/top_level.txt +0 -0
plotnine/themes/theme.py
CHANGED
|
@@ -19,6 +19,8 @@ if typing.TYPE_CHECKING:
|
|
|
19
19
|
|
|
20
20
|
from plotnine import ggplot
|
|
21
21
|
|
|
22
|
+
from .elements import margin
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
# All complete themes are initiated with these rcparams. They
|
|
24
26
|
# can be overridden.
|
|
@@ -122,6 +124,11 @@ class theme:
|
|
|
122
124
|
plot_title=None,
|
|
123
125
|
plot_subtitle=None,
|
|
124
126
|
plot_caption=None,
|
|
127
|
+
plot_tag=None,
|
|
128
|
+
plot_title_position=None,
|
|
129
|
+
plot_caption_position=None,
|
|
130
|
+
plot_tag_location=None,
|
|
131
|
+
plot_tag_position=None,
|
|
125
132
|
strip_text_x=None,
|
|
126
133
|
strip_text_y=None,
|
|
127
134
|
strip_text=None,
|
|
@@ -169,13 +176,6 @@ class theme:
|
|
|
169
176
|
axis_ticks_length_minor_y=None,
|
|
170
177
|
axis_ticks_length_minor=None,
|
|
171
178
|
axis_ticks_length=None,
|
|
172
|
-
axis_ticks_pad_major_x=None,
|
|
173
|
-
axis_ticks_pad_major_y=None,
|
|
174
|
-
axis_ticks_pad_major=None,
|
|
175
|
-
axis_ticks_pad_minor_x=None,
|
|
176
|
-
axis_ticks_pad_minor_y=None,
|
|
177
|
-
axis_ticks_pad_minor=None,
|
|
178
|
-
axis_ticks_pad=None,
|
|
179
179
|
panel_spacing_x=None,
|
|
180
180
|
panel_spacing_y=None,
|
|
181
181
|
panel_spacing=None,
|
|
@@ -270,6 +270,20 @@ class theme:
|
|
|
270
270
|
"""
|
|
271
271
|
return self.themeables.getp
|
|
272
272
|
|
|
273
|
+
def get_margin(self, name: str) -> margin:
|
|
274
|
+
"""
|
|
275
|
+
Return the margin propery of a element_text themeables
|
|
276
|
+
"""
|
|
277
|
+
return self.themeables.getp((name, "margin"))
|
|
278
|
+
|
|
279
|
+
@cached_property
|
|
280
|
+
def get_ha(self):
|
|
281
|
+
return self.themeables.get_ha
|
|
282
|
+
|
|
283
|
+
@cached_property
|
|
284
|
+
def get_va(self):
|
|
285
|
+
return self.themeables.get_va
|
|
286
|
+
|
|
273
287
|
def apply(self):
|
|
274
288
|
"""
|
|
275
289
|
Apply this theme, then apply additional modifications in order.
|
plotnine/themes/theme_538.py
CHANGED
|
@@ -23,7 +23,6 @@ class theme_538(theme_gray):
|
|
|
23
23
|
axis_ticks=element_blank(),
|
|
24
24
|
title=element_text(color="#3C3C3C"),
|
|
25
25
|
legend_background=element_rect(fill="none"),
|
|
26
|
-
legend_key=element_rect(fill="#E0E0E0"),
|
|
27
26
|
panel_background=element_rect(fill=bgcolor),
|
|
28
27
|
panel_border=element_blank(),
|
|
29
28
|
panel_grid_major=element_line(color="#D5D5D5"),
|
plotnine/themes/theme_bw.py
CHANGED
|
@@ -20,7 +20,6 @@ class theme_bw(theme_gray):
|
|
|
20
20
|
super().__init__(base_size, base_family)
|
|
21
21
|
self += theme(
|
|
22
22
|
axis_text=element_text(size=0.8 * base_size),
|
|
23
|
-
legend_key=element_rect(fill="none", color="#CCCCCC"),
|
|
24
23
|
panel_background=element_rect(fill="white"),
|
|
25
24
|
panel_border=element_rect(fill="none", color="#7f7f7f"),
|
|
26
25
|
panel_grid_major=element_line(color="#E5E5E5"),
|
plotnine/themes/theme_dark.py
CHANGED
|
@@ -24,7 +24,6 @@ class theme_dark(theme_gray):
|
|
|
24
24
|
self += theme(
|
|
25
25
|
axis_ticks=element_line(color="#666666", size=0.5),
|
|
26
26
|
axis_ticks_minor=element_blank(),
|
|
27
|
-
legend_key=element_rect(fill="#7F7F7F", color="#666666", size=0.5),
|
|
28
27
|
panel_background=element_rect(fill="#7F7F7F", color="none"),
|
|
29
28
|
panel_grid_major=element_line(color="#666666", size=0.5),
|
|
30
29
|
panel_grid_minor=element_line(color="#737373", size=0.25),
|
plotnine/themes/theme_gray.py
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
from .._utils.registry import alias
|
|
2
2
|
from ..options import get_option
|
|
3
|
-
from .elements import
|
|
3
|
+
from .elements import (
|
|
4
|
+
element_blank,
|
|
5
|
+
element_line,
|
|
6
|
+
element_rect,
|
|
7
|
+
element_text,
|
|
8
|
+
margin,
|
|
9
|
+
margin_auto,
|
|
10
|
+
)
|
|
4
11
|
from .theme import theme
|
|
5
12
|
|
|
6
13
|
|
|
@@ -21,6 +28,7 @@ class theme_gray(theme):
|
|
|
21
28
|
|
|
22
29
|
def __init__(self, base_size=11, base_family=None):
|
|
23
30
|
base_family = base_family or get_option("base_family")
|
|
31
|
+
half_line = base_size / 2
|
|
24
32
|
quarter_line = base_size / 4
|
|
25
33
|
fifth_line = base_size / 5
|
|
26
34
|
eighth_line = base_size / 8
|
|
@@ -37,32 +45,32 @@ class theme_gray(theme):
|
|
|
37
45
|
family=base_family,
|
|
38
46
|
style="normal",
|
|
39
47
|
color="black",
|
|
48
|
+
ma="center",
|
|
40
49
|
size=base_size,
|
|
41
50
|
linespacing=0.9,
|
|
42
51
|
rotation=0,
|
|
43
|
-
margin=
|
|
52
|
+
margin=margin(),
|
|
44
53
|
),
|
|
45
54
|
aspect_ratio=get_option("aspect_ratio"),
|
|
46
55
|
axis_line=element_line(),
|
|
47
56
|
axis_line_x=element_blank(),
|
|
48
57
|
axis_line_y=element_blank(),
|
|
49
58
|
axis_text=element_text(size=base_size * 0.8, color="#4D4D4D"),
|
|
50
|
-
axis_text_x=element_text(va="top", margin=
|
|
51
|
-
axis_text_y=element_text(ha="right", margin=
|
|
59
|
+
axis_text_x=element_text(va="top", margin=margin(t=fifth_line)),
|
|
60
|
+
axis_text_y=element_text(ha="right", margin=margin(r=fifth_line)),
|
|
52
61
|
axis_ticks=element_line(color="#333333"),
|
|
53
62
|
axis_ticks_length=0,
|
|
54
63
|
axis_ticks_length_major=quarter_line,
|
|
55
64
|
axis_ticks_length_minor=eighth_line,
|
|
56
65
|
axis_ticks_minor=element_blank(),
|
|
57
|
-
axis_ticks_pad=2,
|
|
58
66
|
axis_title_x=element_text(
|
|
59
|
-
va="bottom", ha="center", margin=
|
|
67
|
+
va="bottom", ha="center", margin=margin(t=m, unit="fig")
|
|
60
68
|
),
|
|
61
69
|
axis_title_y=element_text(
|
|
62
70
|
angle=90,
|
|
63
71
|
va="center",
|
|
64
72
|
ha="left",
|
|
65
|
-
margin=
|
|
73
|
+
margin=margin(r=m, unit="fig"),
|
|
66
74
|
),
|
|
67
75
|
dpi=get_option("dpi"),
|
|
68
76
|
figure_size=get_option("figure_size"),
|
|
@@ -75,7 +83,6 @@ class theme_gray(theme):
|
|
|
75
83
|
legend_frame=element_blank(),
|
|
76
84
|
legend_key_spacing_x=6,
|
|
77
85
|
legend_key_spacing_y=2,
|
|
78
|
-
legend_key=element_rect(fill="#F2F2F2", colour="none"),
|
|
79
86
|
legend_key_size=base_size * 0.8 * 1.8,
|
|
80
87
|
legend_ticks_length=0.2,
|
|
81
88
|
legend_margin=0, # points
|
|
@@ -83,25 +90,13 @@ class theme_gray(theme):
|
|
|
83
90
|
legend_spacing=10, # points
|
|
84
91
|
legend_text=element_text(
|
|
85
92
|
size=base_size * 0.8,
|
|
86
|
-
margin=
|
|
87
|
-
"t": m / 1.5,
|
|
88
|
-
"b": m / 1.5,
|
|
89
|
-
"l": m / 1.5,
|
|
90
|
-
"r": m / 1.5,
|
|
91
|
-
"units": "fig",
|
|
92
|
-
},
|
|
93
|
+
margin=margin_auto(m / 1.5, unit="fig"),
|
|
93
94
|
),
|
|
94
95
|
legend_ticks=element_line(color="#CCCCCC", size=1),
|
|
95
96
|
legend_title=element_text(
|
|
96
|
-
margin=
|
|
97
|
-
"t": m,
|
|
98
|
-
"b": m / 2,
|
|
99
|
-
"l": m * 2,
|
|
100
|
-
"r": m * 2,
|
|
101
|
-
"units": "fig",
|
|
102
|
-
},
|
|
97
|
+
margin=margin(t=m, l=m * 2, b=m / 2, r=m * 2, unit="fig")
|
|
103
98
|
),
|
|
104
|
-
panel_background=element_rect(fill="#EBEBEB"),
|
|
99
|
+
panel_background=element_rect(fill="#EBEBEB", color="none"),
|
|
105
100
|
panel_border=element_blank(),
|
|
106
101
|
panel_grid_major=element_line(color="white", size=1),
|
|
107
102
|
panel_grid_minor=element_line(color="white", size=0.5),
|
|
@@ -112,20 +107,29 @@ class theme_gray(theme):
|
|
|
112
107
|
ha="right",
|
|
113
108
|
va="bottom",
|
|
114
109
|
ma="left",
|
|
115
|
-
margin=
|
|
110
|
+
margin=margin(t=m, unit="fig"),
|
|
116
111
|
),
|
|
117
112
|
plot_margin=m,
|
|
118
113
|
plot_subtitle=element_text(
|
|
119
114
|
va="top",
|
|
120
115
|
ma="left",
|
|
121
|
-
margin=
|
|
116
|
+
margin=margin(b=m, unit="fig"),
|
|
122
117
|
),
|
|
123
118
|
plot_title=element_text(
|
|
124
119
|
size=base_size * 1.2,
|
|
125
120
|
va="top",
|
|
126
121
|
ma="left",
|
|
127
|
-
margin=
|
|
122
|
+
margin=margin(b=m, unit="fig"),
|
|
128
123
|
),
|
|
124
|
+
plot_tag=element_text(
|
|
125
|
+
size=base_size * 1.2,
|
|
126
|
+
va="center",
|
|
127
|
+
ha="center",
|
|
128
|
+
),
|
|
129
|
+
plot_title_position="panel",
|
|
130
|
+
plot_caption_position="panel",
|
|
131
|
+
plot_tag_location="margin",
|
|
132
|
+
plot_tag_position="topleft",
|
|
129
133
|
strip_align=0,
|
|
130
134
|
strip_background=element_rect(color="none", fill="#D9D9D9"),
|
|
131
135
|
strip_background_x=element_rect(width=1),
|
|
@@ -133,14 +137,8 @@ class theme_gray(theme):
|
|
|
133
137
|
strip_text=element_text(
|
|
134
138
|
color="#1A1A1A",
|
|
135
139
|
size=base_size * 0.8,
|
|
136
|
-
linespacing=1.
|
|
137
|
-
margin=
|
|
138
|
-
"t": 1 / 3,
|
|
139
|
-
"b": 1 / 3,
|
|
140
|
-
"l": 1 / 3,
|
|
141
|
-
"r": 1 / 3,
|
|
142
|
-
"units": "lines",
|
|
143
|
-
},
|
|
140
|
+
linespacing=1.5,
|
|
141
|
+
margin=margin_auto(half_line * 0.8),
|
|
144
142
|
),
|
|
145
143
|
strip_text_y=element_text(rotation=-90),
|
|
146
144
|
complete=True,
|
plotnine/themes/theme_light.py
CHANGED
|
@@ -24,7 +24,7 @@ class theme_light(theme_gray):
|
|
|
24
24
|
self += theme(
|
|
25
25
|
axis_ticks=element_line(color="#B3B3B3", size=0.5),
|
|
26
26
|
axis_ticks_minor=element_blank(),
|
|
27
|
-
legend_key=element_rect(
|
|
27
|
+
legend_key=element_rect(color="#7F7F7F", size=0.72),
|
|
28
28
|
panel_background=element_rect(fill="white"),
|
|
29
29
|
panel_border=element_rect(fill="none", color="#B3B3B3", size=1),
|
|
30
30
|
panel_grid_major=element_line(color="#D9D9D9", size=0.5),
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
from ..options import get_option
|
|
2
|
-
from .elements import
|
|
2
|
+
from .elements import (
|
|
3
|
+
element_blank,
|
|
4
|
+
element_line,
|
|
5
|
+
element_rect,
|
|
6
|
+
element_text,
|
|
7
|
+
margin,
|
|
8
|
+
margin_auto,
|
|
9
|
+
)
|
|
3
10
|
from .theme import theme
|
|
4
11
|
|
|
5
12
|
|
|
@@ -27,6 +34,7 @@ class theme_matplotlib(theme):
|
|
|
27
34
|
m = get_option("base_margin")
|
|
28
35
|
base_size = mpl.rcParams.get("font.size", 11)
|
|
29
36
|
linewidth = mpl.rcParams.get("grid.linewidth", 0.8)
|
|
37
|
+
half_line = base_size / 2
|
|
30
38
|
|
|
31
39
|
super().__init__(
|
|
32
40
|
line=element_line(size=linewidth),
|
|
@@ -38,16 +46,16 @@ class theme_matplotlib(theme):
|
|
|
38
46
|
margin={},
|
|
39
47
|
),
|
|
40
48
|
aspect_ratio=get_option("aspect_ratio"),
|
|
41
|
-
axis_text=element_text(margin=
|
|
49
|
+
axis_text=element_text(margin=margin(t=2.4, r=2.4, unit="pt")),
|
|
42
50
|
axis_title_x=element_text(
|
|
43
|
-
va="bottom", ha="center", margin=
|
|
51
|
+
va="bottom", ha="center", margin=margin(t=m, unit="fig")
|
|
44
52
|
),
|
|
45
53
|
axis_line=element_blank(),
|
|
46
54
|
axis_title_y=element_text(
|
|
47
55
|
angle=90,
|
|
48
56
|
va="center",
|
|
49
57
|
ha="left",
|
|
50
|
-
margin=
|
|
58
|
+
margin=margin(r=m, unit="fig"),
|
|
51
59
|
),
|
|
52
60
|
dpi=get_option("dpi"),
|
|
53
61
|
figure_size=get_option("figure_size"),
|
|
@@ -57,31 +65,16 @@ class theme_matplotlib(theme):
|
|
|
57
65
|
legend_key_spacing_x=6,
|
|
58
66
|
legend_key_spacing_y=2,
|
|
59
67
|
legend_frame=element_rect(color="black"),
|
|
60
|
-
legend_key=element_blank(),
|
|
61
68
|
legend_key_size=16,
|
|
62
69
|
legend_ticks_length=0.2,
|
|
63
70
|
legend_margin=0,
|
|
64
71
|
legend_position="right",
|
|
65
72
|
legend_spacing=10,
|
|
66
|
-
legend_text=element_text(
|
|
67
|
-
margin={
|
|
68
|
-
"t": m / 2,
|
|
69
|
-
"b": m / 2,
|
|
70
|
-
"l": m / 2,
|
|
71
|
-
"r": m / 2,
|
|
72
|
-
"units": "fig",
|
|
73
|
-
}
|
|
74
|
-
),
|
|
73
|
+
legend_text=element_text(margin=margin_auto(m / 2, unit="fig")),
|
|
75
74
|
legend_ticks=element_line(color="black"),
|
|
76
75
|
legend_title=element_text(
|
|
77
76
|
ha="left",
|
|
78
|
-
margin=
|
|
79
|
-
"t": m,
|
|
80
|
-
"b": m / 2,
|
|
81
|
-
"l": m * 2,
|
|
82
|
-
"r": m * 2,
|
|
83
|
-
"units": "fig",
|
|
84
|
-
},
|
|
77
|
+
margin=margin(t=m, l=m * 2, b=m / 2, r=m * 2, unit="fig"),
|
|
85
78
|
),
|
|
86
79
|
panel_border=element_rect(color="black"),
|
|
87
80
|
panel_grid=element_blank(),
|
|
@@ -90,32 +83,36 @@ class theme_matplotlib(theme):
|
|
|
90
83
|
ha="right",
|
|
91
84
|
va="bottom",
|
|
92
85
|
ma="left",
|
|
93
|
-
margin=
|
|
86
|
+
margin=margin(t=m, unit="fig"),
|
|
94
87
|
),
|
|
95
88
|
plot_margin=m,
|
|
96
89
|
plot_subtitle=element_text(
|
|
97
90
|
size=base_size * 0.9,
|
|
98
91
|
va="top",
|
|
99
92
|
ma="left",
|
|
100
|
-
margin=
|
|
93
|
+
margin=margin(b=m, unit="fig"),
|
|
101
94
|
),
|
|
102
95
|
plot_title=element_text(
|
|
103
96
|
va="top",
|
|
104
97
|
ma="left",
|
|
105
|
-
margin=
|
|
98
|
+
margin=margin(b=m, unit="fig"),
|
|
99
|
+
),
|
|
100
|
+
plot_tag=element_text(
|
|
101
|
+
size=base_size * 1.2,
|
|
102
|
+
va="center",
|
|
103
|
+
ha="center",
|
|
106
104
|
),
|
|
105
|
+
plot_title_position="panel",
|
|
106
|
+
plot_caption_position="panel",
|
|
107
|
+
plot_tag_location="margin",
|
|
108
|
+
plot_tag_position="topleft",
|
|
107
109
|
strip_align=0,
|
|
108
110
|
strip_background=element_rect(
|
|
109
111
|
fill="#D9D9D9", color="black", size=linewidth
|
|
110
112
|
),
|
|
111
113
|
strip_text=element_text(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"b": 1 / 3,
|
|
115
|
-
"l": 1 / 3,
|
|
116
|
-
"r": 1 / 3,
|
|
117
|
-
"units": "lines",
|
|
118
|
-
},
|
|
114
|
+
linespacing=1.5,
|
|
115
|
+
margin=margin_auto(half_line * 0.8),
|
|
119
116
|
),
|
|
120
117
|
strip_text_y=element_text(rotation=-90),
|
|
121
118
|
complete=True,
|
plotnine/themes/theme_seaborn.py
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
from ..options import get_option
|
|
2
|
-
from .elements import
|
|
2
|
+
from .elements import (
|
|
3
|
+
element_blank,
|
|
4
|
+
element_line,
|
|
5
|
+
element_rect,
|
|
6
|
+
element_text,
|
|
7
|
+
margin,
|
|
8
|
+
margin_auto,
|
|
9
|
+
)
|
|
3
10
|
from .theme import theme
|
|
4
11
|
|
|
5
12
|
|
|
@@ -14,7 +21,7 @@ class theme_seaborn(theme):
|
|
|
14
21
|
|
|
15
22
|
Parameters
|
|
16
23
|
----------
|
|
17
|
-
style: "
|
|
24
|
+
style: "white", "dark", "whitegrid", "darkgrid", "ticks"
|
|
18
25
|
Style of axis background.
|
|
19
26
|
context: "notebook", "talk", "paper", "poster"]``
|
|
20
27
|
Intended context for resulting figures.
|
|
@@ -49,22 +56,22 @@ class theme_seaborn(theme):
|
|
|
49
56
|
text=element_text(size=base_size, rotation=0, margin={}),
|
|
50
57
|
axis_text=element_text(
|
|
51
58
|
size=base_size * 0.8,
|
|
52
|
-
margin=
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
+
margin=margin(
|
|
60
|
+
t=line_margin,
|
|
61
|
+
b=line_margin,
|
|
62
|
+
l=line_margin,
|
|
63
|
+
r=line_margin,
|
|
64
|
+
unit="pt",
|
|
65
|
+
),
|
|
59
66
|
),
|
|
60
67
|
axis_title_x=element_text(
|
|
61
|
-
va="bottom", ha="center", margin=
|
|
68
|
+
va="bottom", ha="center", margin=margin(t=m, unit="fig")
|
|
62
69
|
),
|
|
63
70
|
axis_title_y=element_text(
|
|
64
71
|
angle=90,
|
|
65
72
|
va="center",
|
|
66
73
|
ha="left",
|
|
67
|
-
margin=
|
|
74
|
+
margin=margin(r=m, unit="fig"),
|
|
68
75
|
),
|
|
69
76
|
legend_box_margin=0,
|
|
70
77
|
legend_box_spacing=m * 3, # figure units
|
|
@@ -77,57 +84,50 @@ class theme_seaborn(theme):
|
|
|
77
84
|
legend_position="right",
|
|
78
85
|
legend_spacing=10, # points
|
|
79
86
|
legend_text=element_text(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"b": m / 1.5,
|
|
83
|
-
"l": m / 1.5,
|
|
84
|
-
"r": m / 1.5,
|
|
85
|
-
"units": "fig",
|
|
86
|
-
},
|
|
87
|
+
size=base_size * 0.8,
|
|
88
|
+
margin=margin_auto(m / 1.5, unit="fig"),
|
|
87
89
|
),
|
|
88
90
|
legend_ticks=element_line(color="#CCCCCC", size=1),
|
|
89
91
|
legend_title=element_text(
|
|
90
|
-
margin=
|
|
91
|
-
"t": m,
|
|
92
|
-
"b": m / 2,
|
|
93
|
-
"l": m * 2,
|
|
94
|
-
"r": m * 2,
|
|
95
|
-
"units": "fig",
|
|
96
|
-
},
|
|
92
|
+
margin=margin(t=m, l=m * 2, b=m / 2, r=m * 2, unit="fig")
|
|
97
93
|
),
|
|
98
94
|
panel_spacing=m,
|
|
95
|
+
panel_background=element_rect(fill=rcparams["axes.facecolor"]),
|
|
99
96
|
plot_caption=element_text(
|
|
100
97
|
size=base_size * 0.8,
|
|
101
98
|
ha="right",
|
|
102
99
|
va="bottom",
|
|
103
100
|
ma="left",
|
|
104
|
-
margin=
|
|
101
|
+
margin=margin(t=m, unit="fig"),
|
|
105
102
|
),
|
|
106
103
|
plot_margin=m,
|
|
107
104
|
plot_subtitle=element_text(
|
|
108
105
|
size=base_size * 1,
|
|
109
106
|
va="top",
|
|
110
107
|
ma="left",
|
|
111
|
-
margin=
|
|
108
|
+
margin=margin(b=m, unit="fig"),
|
|
112
109
|
),
|
|
113
110
|
plot_title=element_text(
|
|
114
111
|
size=base_size * 1.2,
|
|
115
112
|
va="top",
|
|
116
113
|
ma="left",
|
|
117
|
-
margin=
|
|
114
|
+
margin=margin(b=m, unit="fig"),
|
|
115
|
+
),
|
|
116
|
+
plot_tag=element_text(
|
|
117
|
+
size=base_size * 1.2,
|
|
118
|
+
va="center",
|
|
119
|
+
ha="center",
|
|
118
120
|
),
|
|
121
|
+
plot_title_position="panel",
|
|
122
|
+
plot_caption_position="panel",
|
|
123
|
+
plot_tag_location="margin",
|
|
124
|
+
plot_tag_position="topleft",
|
|
119
125
|
strip_align=0,
|
|
120
126
|
strip_background=element_rect(color="none", fill="#D1CDDF"),
|
|
121
127
|
strip_text=element_text(
|
|
122
128
|
size=base_size * 0.8,
|
|
123
|
-
linespacing=1.
|
|
124
|
-
margin=
|
|
125
|
-
"t": 1 / 3,
|
|
126
|
-
"b": 1 / 3,
|
|
127
|
-
"l": 1 / 3,
|
|
128
|
-
"r": 1 / 3,
|
|
129
|
-
"units": "lines",
|
|
130
|
-
},
|
|
129
|
+
linespacing=1.5,
|
|
130
|
+
margin=margin_auto(half_line * 0.8),
|
|
131
131
|
),
|
|
132
132
|
strip_text_y=element_text(rotation=-90),
|
|
133
133
|
complete=True,
|
plotnine/themes/theme_void.py
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
from ..options import get_option
|
|
2
|
-
from .elements import
|
|
2
|
+
from .elements import (
|
|
3
|
+
element_blank,
|
|
4
|
+
element_line,
|
|
5
|
+
element_text,
|
|
6
|
+
margin,
|
|
7
|
+
margin_auto,
|
|
8
|
+
)
|
|
3
9
|
from .theme import theme
|
|
4
10
|
|
|
5
11
|
|
|
@@ -19,6 +25,7 @@ class theme_void(theme):
|
|
|
19
25
|
|
|
20
26
|
def __init__(self, base_size=11, base_family=None):
|
|
21
27
|
base_family = base_family or get_option("base_family")
|
|
28
|
+
half_line = base_size / 2
|
|
22
29
|
m = get_option("base_margin")
|
|
23
30
|
# Use only inherited elements and make everything blank
|
|
24
31
|
theme.__init__(
|
|
@@ -32,7 +39,7 @@ class theme_void(theme):
|
|
|
32
39
|
size=base_size,
|
|
33
40
|
linespacing=0.9,
|
|
34
41
|
rotation=0,
|
|
35
|
-
margin=
|
|
42
|
+
margin=margin(),
|
|
36
43
|
),
|
|
37
44
|
axis_text_x=element_blank(),
|
|
38
45
|
axis_text_y=element_blank(),
|
|
@@ -54,23 +61,11 @@ class theme_void(theme):
|
|
|
54
61
|
legend_spacing=10,
|
|
55
62
|
legend_text=element_text(
|
|
56
63
|
size=base_size * 0.8,
|
|
57
|
-
margin=
|
|
58
|
-
"t": m / 1.5,
|
|
59
|
-
"b": m / 1.5,
|
|
60
|
-
"l": m / 1.5,
|
|
61
|
-
"r": m / 1.5,
|
|
62
|
-
"units": "fig",
|
|
63
|
-
},
|
|
64
|
+
margin=margin_auto(m / 1.5, unit="fig"),
|
|
64
65
|
),
|
|
65
66
|
legend_ticks=element_line(color="#CCCCCC", size=1),
|
|
66
67
|
legend_title=element_text(
|
|
67
|
-
margin=
|
|
68
|
-
"t": m,
|
|
69
|
-
"b": m / 2,
|
|
70
|
-
"l": m * 2,
|
|
71
|
-
"r": m * 2,
|
|
72
|
-
"units": "fig",
|
|
73
|
-
},
|
|
68
|
+
margin=margin(t=m, l=m * 2, b=m / 2, r=m * 2, unit="fig")
|
|
74
69
|
),
|
|
75
70
|
panel_spacing=m,
|
|
76
71
|
plot_caption=element_text(
|
|
@@ -78,33 +73,36 @@ class theme_void(theme):
|
|
|
78
73
|
ha="right",
|
|
79
74
|
va="bottom",
|
|
80
75
|
ma="left",
|
|
81
|
-
margin=
|
|
76
|
+
margin=margin(t=m, unit="fig"),
|
|
82
77
|
),
|
|
83
78
|
plot_margin=0,
|
|
84
79
|
plot_subtitle=element_text(
|
|
85
80
|
size=base_size * 1,
|
|
86
81
|
va="top",
|
|
87
82
|
ma="left",
|
|
88
|
-
margin=
|
|
83
|
+
margin=margin(b=m, unit="fig"),
|
|
89
84
|
),
|
|
90
85
|
plot_title=element_text(
|
|
91
86
|
size=base_size * 1.2,
|
|
92
87
|
va="top",
|
|
93
88
|
ma="left",
|
|
94
|
-
margin=
|
|
89
|
+
margin=margin(b=m, unit="fig"),
|
|
95
90
|
),
|
|
91
|
+
plot_tag=element_text(
|
|
92
|
+
size=base_size * 1.2,
|
|
93
|
+
va="center",
|
|
94
|
+
ha="center",
|
|
95
|
+
),
|
|
96
|
+
plot_title_position="panel",
|
|
97
|
+
plot_caption_position="panel",
|
|
98
|
+
plot_tag_location="margin",
|
|
99
|
+
plot_tag_position="topleft",
|
|
96
100
|
strip_align=0,
|
|
97
101
|
strip_text=element_text(
|
|
98
102
|
color="#1A1A1A",
|
|
99
103
|
size=base_size * 0.8,
|
|
100
|
-
linespacing=1.
|
|
101
|
-
margin=
|
|
102
|
-
"t": 1 / 3,
|
|
103
|
-
"b": 1 / 3,
|
|
104
|
-
"l": 1 / 3,
|
|
105
|
-
"r": 1 / 3,
|
|
106
|
-
"units": "lines",
|
|
107
|
-
},
|
|
104
|
+
linespacing=1.5,
|
|
105
|
+
margin=margin_auto(half_line * 0.8),
|
|
108
106
|
),
|
|
109
107
|
complete=True,
|
|
110
108
|
)
|
plotnine/themes/theme_xkcd.py
CHANGED
|
@@ -50,7 +50,6 @@ class theme_xkcd(theme_gray):
|
|
|
50
50
|
legend_background=element_rect(color="black"),
|
|
51
51
|
legend_box_margin=2,
|
|
52
52
|
legend_margin=5,
|
|
53
|
-
legend_key=element_rect(fill="none"),
|
|
54
53
|
panel_border=element_rect(color="black", size=1),
|
|
55
54
|
panel_grid=element_blank(),
|
|
56
55
|
panel_background=element_rect(fill="white"),
|