lets-plot 4.8.1rc1__cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.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.
- lets_plot/__init__.py +382 -0
- lets_plot/_global_settings.py +192 -0
- lets_plot/_kbridge.py +197 -0
- lets_plot/_type_utils.py +133 -0
- lets_plot/_version.py +6 -0
- lets_plot/bistro/__init__.py +16 -0
- lets_plot/bistro/_plot2d_common.py +106 -0
- lets_plot/bistro/corr.py +448 -0
- lets_plot/bistro/im.py +196 -0
- lets_plot/bistro/joint.py +192 -0
- lets_plot/bistro/qq.py +207 -0
- lets_plot/bistro/residual.py +341 -0
- lets_plot/bistro/waterfall.py +332 -0
- lets_plot/export/__init__.py +6 -0
- lets_plot/export/ggsave_.py +172 -0
- lets_plot/frontend_context/__init__.py +8 -0
- lets_plot/frontend_context/_configuration.py +140 -0
- lets_plot/frontend_context/_dynamic_configure_html.py +115 -0
- lets_plot/frontend_context/_frontend_ctx.py +16 -0
- lets_plot/frontend_context/_html_contexts.py +223 -0
- lets_plot/frontend_context/_intellij_python_json_ctx.py +38 -0
- lets_plot/frontend_context/_isolated_webview_panel_ctx.py +81 -0
- lets_plot/frontend_context/_json_contexts.py +39 -0
- lets_plot/frontend_context/_jupyter_notebook_ctx.py +82 -0
- lets_plot/frontend_context/_mime_types.py +7 -0
- lets_plot/frontend_context/_static_html_page_ctx.py +76 -0
- lets_plot/frontend_context/_static_svg_ctx.py +26 -0
- lets_plot/frontend_context/_webbr_html_page_ctx.py +29 -0
- lets_plot/frontend_context/sandbox.py +5 -0
- lets_plot/geo_data/__init__.py +19 -0
- lets_plot/geo_data/core.py +335 -0
- lets_plot/geo_data/geocoder.py +988 -0
- lets_plot/geo_data/geocodes.py +512 -0
- lets_plot/geo_data/gis/__init__.py +0 -0
- lets_plot/geo_data/gis/fluent_dict.py +201 -0
- lets_plot/geo_data/gis/geocoding_service.py +42 -0
- lets_plot/geo_data/gis/geometry.py +91 -0
- lets_plot/geo_data/gis/json_request.py +232 -0
- lets_plot/geo_data/gis/json_response.py +308 -0
- lets_plot/geo_data/gis/request.py +492 -0
- lets_plot/geo_data/gis/response.py +247 -0
- lets_plot/geo_data/livemap_helper.py +65 -0
- lets_plot/geo_data/to_geo_data_frame.py +141 -0
- lets_plot/geo_data/type_assertion.py +34 -0
- lets_plot/geo_data_internals/__init__.py +4 -0
- lets_plot/geo_data_internals/constants.py +13 -0
- lets_plot/geo_data_internals/utils.py +33 -0
- lets_plot/mapping.py +115 -0
- lets_plot/package_data/lets-plot.min.js +3 -0
- lets_plot/plot/__init__.py +64 -0
- lets_plot/plot/_global_theme.py +14 -0
- lets_plot/plot/annotation.py +290 -0
- lets_plot/plot/coord.py +242 -0
- lets_plot/plot/core.py +1071 -0
- lets_plot/plot/expand_limits_.py +78 -0
- lets_plot/plot/facet.py +210 -0
- lets_plot/plot/font_features.py +71 -0
- lets_plot/plot/geom.py +9146 -0
- lets_plot/plot/geom_extras.py +53 -0
- lets_plot/plot/geom_function_.py +219 -0
- lets_plot/plot/geom_imshow_.py +393 -0
- lets_plot/plot/geom_livemap_.py +343 -0
- lets_plot/plot/ggbunch_.py +96 -0
- lets_plot/plot/gggrid_.py +139 -0
- lets_plot/plot/ggtb_.py +81 -0
- lets_plot/plot/guide.py +231 -0
- lets_plot/plot/label.py +187 -0
- lets_plot/plot/marginal_layer.py +181 -0
- lets_plot/plot/plot.py +245 -0
- lets_plot/plot/pos.py +344 -0
- lets_plot/plot/sampling.py +338 -0
- lets_plot/plot/sandbox_.py +26 -0
- lets_plot/plot/scale.py +3580 -0
- lets_plot/plot/scale_colormap_mpl.py +300 -0
- lets_plot/plot/scale_convenience.py +155 -0
- lets_plot/plot/scale_identity_.py +653 -0
- lets_plot/plot/scale_position.py +1342 -0
- lets_plot/plot/series_meta.py +209 -0
- lets_plot/plot/stat.py +585 -0
- lets_plot/plot/subplots.py +331 -0
- lets_plot/plot/subplots_util.py +24 -0
- lets_plot/plot/theme_.py +790 -0
- lets_plot/plot/theme_set.py +418 -0
- lets_plot/plot/tooltip.py +486 -0
- lets_plot/plot/util.py +267 -0
- lets_plot/settings_utils.py +244 -0
- lets_plot/tilesets.py +429 -0
- lets_plot-4.8.1rc1.dist-info/METADATA +221 -0
- lets_plot-4.8.1rc1.dist-info/RECORD +97 -0
- lets_plot-4.8.1rc1.dist-info/WHEEL +6 -0
- lets_plot-4.8.1rc1.dist-info/licenses/LICENSE +21 -0
- lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.FreeType +166 -0
- lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.ImageMagick +106 -0
- lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.expat +21 -0
- lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.fontconfig +200 -0
- lets_plot-4.8.1rc1.dist-info/top_level.txt +2 -0
- lets_plot_kotlin_bridge.cpython-311-x86_64-linux-gnu.so +0 -0
lets_plot/plot/theme_.py
ADDED
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2019. JetBrains s.r.o.
|
|
3
|
+
# Use of this source code is governed by the MIT license that can be found in the LICENSE file.
|
|
4
|
+
#
|
|
5
|
+
from .core import FeatureSpec
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'theme',
|
|
9
|
+
'element_blank',
|
|
10
|
+
"element_line",
|
|
11
|
+
'element_rect',
|
|
12
|
+
'element_text',
|
|
13
|
+
'element_markdown',
|
|
14
|
+
'margin',
|
|
15
|
+
'element_geom',
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def theme(*,
|
|
20
|
+
exponent_format=None,
|
|
21
|
+
|
|
22
|
+
line=None,
|
|
23
|
+
rect=None,
|
|
24
|
+
text=None,
|
|
25
|
+
title=None,
|
|
26
|
+
# ToDo: aspect.ratio
|
|
27
|
+
axis=None,
|
|
28
|
+
axis_ontop=None, axis_ontop_x=None, axis_ontop_y=None,
|
|
29
|
+
axis_title=None, axis_title_x=None, axis_title_y=None,
|
|
30
|
+
# ToDo: axis.title.x.top, axis.title.x.bottom
|
|
31
|
+
# ToDo: axis.title.y.left, axis.title.y.right
|
|
32
|
+
axis_text=None, axis_text_x=None, axis_text_y=None,
|
|
33
|
+
# ToDo: axis.text.x.top, axis.text.x.bottom
|
|
34
|
+
# ToDo: axis.text.x.left, axis.text.x.right
|
|
35
|
+
axis_text_spacing=None, axis_text_spacing_x=None, axis_text_spacing_y=None,
|
|
36
|
+
axis_ticks=None, axis_ticks_x=None, axis_ticks_y=None,
|
|
37
|
+
# ToDo: axis.ticks.x.top, axis.ticks.x.bottom
|
|
38
|
+
# ToDo: axis.ticks.x.left, axis.ticks.x.right
|
|
39
|
+
axis_ticks_length=None, axis_ticks_length_x=None, axis_ticks_length_y=None,
|
|
40
|
+
axis_line=None, axis_line_x=None, axis_line_y=None,
|
|
41
|
+
# ToDo: axis.line.x.top, axis.line.x.bottom
|
|
42
|
+
# ToDo: axis.line.x.left, axis.line.x.right
|
|
43
|
+
|
|
44
|
+
legend_background=None,
|
|
45
|
+
legend_text=None, legend_title=None,
|
|
46
|
+
legend_position=None, legend_justification=None, legend_direction=None,
|
|
47
|
+
legend_margin=None,
|
|
48
|
+
legend_spacing=None, legend_spacing_x=None,legend_spacing_y=None,
|
|
49
|
+
legend_key=None,
|
|
50
|
+
legend_key_size=None, legend_key_width=None, legend_key_height=None,
|
|
51
|
+
legend_key_spacing=None, legend_key_spacing_x=None, legend_key_spacing_y=None,
|
|
52
|
+
legend_box=None, legend_box_just=None, legend_box_spacing=None,
|
|
53
|
+
legend_ticks=None, legend_ticks_length=None,
|
|
54
|
+
|
|
55
|
+
panel_background=None,
|
|
56
|
+
panel_border=None,
|
|
57
|
+
panel_border_ontop=None,
|
|
58
|
+
|
|
59
|
+
panel_grid=None,
|
|
60
|
+
panel_grid_ontop=None,
|
|
61
|
+
panel_grid_ontop_x=None,
|
|
62
|
+
panel_grid_ontop_y=None,
|
|
63
|
+
panel_grid_major=None,
|
|
64
|
+
panel_grid_minor=None,
|
|
65
|
+
panel_grid_major_x=None,
|
|
66
|
+
panel_grid_minor_x=None,
|
|
67
|
+
panel_grid_major_y=None,
|
|
68
|
+
panel_grid_minor_y=None,
|
|
69
|
+
panel_inset=None,
|
|
70
|
+
|
|
71
|
+
plot_background=None,
|
|
72
|
+
plot_title=None,
|
|
73
|
+
plot_subtitle=None,
|
|
74
|
+
plot_caption=None,
|
|
75
|
+
plot_message=None,
|
|
76
|
+
plot_margin=None,
|
|
77
|
+
plot_inset=None,
|
|
78
|
+
|
|
79
|
+
plot_title_position=None,
|
|
80
|
+
plot_caption_position=None,
|
|
81
|
+
|
|
82
|
+
strip_background=None, strip_background_x=None, strip_background_y=None,
|
|
83
|
+
strip_text=None, strip_text_x=None, strip_text_y=None,
|
|
84
|
+
strip_spacing=None, strip_spacing_x=None, strip_spacing_y=None,
|
|
85
|
+
panel_spacing=None, panel_spacing_x=None, panel_spacing_y=None,
|
|
86
|
+
# ToDo: strip.placement
|
|
87
|
+
|
|
88
|
+
axis_tooltip=None, axis_tooltip_x=None, axis_tooltip_y=None,
|
|
89
|
+
axis_tooltip_text=None, axis_tooltip_text_x=None, axis_tooltip_text_y=None,
|
|
90
|
+
|
|
91
|
+
tooltip=None,
|
|
92
|
+
tooltip_text=None, tooltip_title_text=None,
|
|
93
|
+
|
|
94
|
+
label_text=None,
|
|
95
|
+
|
|
96
|
+
geom=None
|
|
97
|
+
):
|
|
98
|
+
"""
|
|
99
|
+
Use ``theme()`` to modify individual components of a theme,
|
|
100
|
+
allowing you to control all non-data components of the plot.
|
|
101
|
+
See also the `Plot Layout Diagrams <https://lets-plot.org/python/pages/charts.html#plot-layout-diagrams>`__ section.
|
|
102
|
+
|
|
103
|
+
Parameters
|
|
104
|
+
----------
|
|
105
|
+
exponent_format : {'e', 'pow', 'pow_full'} or tuple, default='pow'
|
|
106
|
+
Controls the appearance of numbers formatted with 'e' or 'g' types.
|
|
107
|
+
|
|
108
|
+
Value is either a string - style, or a tuple: (style, lower_exp_bound, upper_exp_bound)
|
|
109
|
+
where style can be:
|
|
110
|
+
|
|
111
|
+
- 'e' : e-notation (e.g., 1e+6)
|
|
112
|
+
- 'pow' : superscript powers of 10 in shortened form (e.g., 10^6)
|
|
113
|
+
- 'pow_full' : superscript powers of 10 with coefficient (e.g., 1×10^6)
|
|
114
|
+
|
|
115
|
+
For 'g' type formatting, scientific notation is applied when the number's exponent
|
|
116
|
+
is less than or equal to the lower_exp_bound (-7 by default) or greater than or equal
|
|
117
|
+
to the upper_exp_bound (6 by default, but can be affected by ``precision`` in format specifier).
|
|
118
|
+
|
|
119
|
+
See `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
120
|
+
|
|
121
|
+
Superscript is not supported when exporting to PNG/PDF.
|
|
122
|
+
line : str or dict
|
|
123
|
+
Style settings for all line elements.
|
|
124
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
125
|
+
Set `element_line() <https://lets-plot.org/python/pages/api/lets_plot.element_line.html>`__ to specify line parameters.
|
|
126
|
+
rect : str or dict
|
|
127
|
+
Style settings for all rectangular elements.
|
|
128
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
129
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify rectangular element parameters.
|
|
130
|
+
text : str or dict
|
|
131
|
+
Style settings for all text elements.
|
|
132
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
133
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify text parameters.
|
|
134
|
+
title : str or dict
|
|
135
|
+
Style settings for all title elements: plot, axes, legends.
|
|
136
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
137
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify title text parameters, inherited from ``text``.
|
|
138
|
+
axis : str or dict
|
|
139
|
+
Style settings for all axis elements: lines, ticks, texts, titles.
|
|
140
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
141
|
+
Set `element_line() <https://lets-plot.org/python/pages/api/lets_plot.element_line.html>`__ to specify axes parameters.
|
|
142
|
+
axis_ontop, axis_ontop_x, axis_ontop_y : bool, default=True
|
|
143
|
+
Option to place axis (lines, tickmarks and labels) over the data layers.
|
|
144
|
+
axis_title, axis_title_x, axis_title_y : str or dict
|
|
145
|
+
Style settings for axis titles.
|
|
146
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
147
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify axis title parameters.
|
|
148
|
+
``axis_title_*`` inherits from ``axis_title`` which inherits from ``text``.
|
|
149
|
+
axis_text, axis_text_x, axis_text_y : str or dict
|
|
150
|
+
Style settings for tick labels along axes.
|
|
151
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
152
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify all axes tick label parameters.
|
|
153
|
+
``axis_text_*`` inherits from ``axis_text`` which inherits from ``text``.
|
|
154
|
+
axis_text_spacing, axis_text_spacing_x, axis_text_spacing_y : float
|
|
155
|
+
Spacing between the axis label text and its tick mark.
|
|
156
|
+
axis_ticks, axis_ticks_x, axis_ticks_y : str or dict
|
|
157
|
+
Style settings for tick marks along axes.
|
|
158
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
159
|
+
Set `element_line() <https://lets-plot.org/python/pages/api/lets_plot.element_line.html>`__ to specify all tick mark parameters.
|
|
160
|
+
``axis_ticks_*`` inherits from ``axis_ticks`` which inherits from ``line``.
|
|
161
|
+
axis_ticks_length, axis_ticks_length_x, axis_ticks_length_y : float
|
|
162
|
+
Length of tick marks in px.
|
|
163
|
+
axis_line, axis_line_x, axis_line_y : str or dict
|
|
164
|
+
Style settings for lines along axes.
|
|
165
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
166
|
+
Set `element_line() <https://lets-plot.org/python/pages/api/lets_plot.element_line.html>`__ to specify line parameters along all axes.
|
|
167
|
+
``axis_line_*`` inherits from ``axis_line`` which inherits from ``line``.
|
|
168
|
+
legend_background : str or dict
|
|
169
|
+
Style settings for background of legend.
|
|
170
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
171
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify legend background parameters, inherited from ``rect``.
|
|
172
|
+
legend_text : str or dict
|
|
173
|
+
Style settings for legend item labels.
|
|
174
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
175
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify legend item label parameters, inherited from ``text``.
|
|
176
|
+
legend_title : str or dict
|
|
177
|
+
Style settings for legend title.
|
|
178
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
179
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify legend title parameters, inherited from ``title``.
|
|
180
|
+
legend_position : {'none', 'left', 'right', 'bottom', 'top'} or list
|
|
181
|
+
The position of legends.
|
|
182
|
+
To remove the plot legend, use the 'none' value.
|
|
183
|
+
If parameter is a list, then it should be a two-element numeric vector [x, y], where each value is between 0 and 1.
|
|
184
|
+
These coordinates position the legend inside the plotting area, where [0, 0] is the bottom left corner and [1, 1] is the top right corner.
|
|
185
|
+
The anchor point of the legend box can be controlled with ``legend_justification``.
|
|
186
|
+
legend_justification : {'center', 'left', 'right', 'top', 'bottom'} or list
|
|
187
|
+
Anchor point of the legend box for positioning.
|
|
188
|
+
Determines which point of the legend box is placed at the coordinates specified by ``legend_position``.
|
|
189
|
+
If parameter is a list, then it should be a two-element numeric vector [x, y], where each value is between 0 and 1.
|
|
190
|
+
The pair [0, 0] corresponds to the bottom left corner of the legend box, and [1, 1] corresponds to the top right corner.
|
|
191
|
+
legend_direction : {'horizontal', 'vertical'}
|
|
192
|
+
Layout of items in legends.
|
|
193
|
+
legend_margin : number or list of numbers
|
|
194
|
+
Margin around each legend.
|
|
195
|
+
The margin may be specified using a number or a list of numbers:
|
|
196
|
+
|
|
197
|
+
- a number or list of one number - the same margin is applied to all four sides;
|
|
198
|
+
- a list of two numbers - the first margin applies to the top and bottom, the second - to the left and right;
|
|
199
|
+
- a list of three numbers - the first margin applies to the top, the second - to the right and left, the third - to the bottom;
|
|
200
|
+
- a list of four numbers - the margins are applied to the top, right, bottom and left in that order.
|
|
201
|
+
|
|
202
|
+
It is acceptable to use None for any side; in this case, the default value for the legend margin side will be used.
|
|
203
|
+
legend_spacing : float
|
|
204
|
+
Spacing between legends.
|
|
205
|
+
legend_spacing_x : float
|
|
206
|
+
Spacing between legends in the horizontal direction, inherited from ``legend_spacing``.
|
|
207
|
+
legend_spacing_y : float
|
|
208
|
+
Spacing between legends in the vertical direction, inherited from ``legend_spacing``.
|
|
209
|
+
legend_key : str or dict
|
|
210
|
+
Style settings for legend key background.
|
|
211
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
212
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify legend key background parameters, inherited from ``rect``.
|
|
213
|
+
legend_key_size : float
|
|
214
|
+
Size of legend keys.
|
|
215
|
+
legend_key_width : float
|
|
216
|
+
Key background width, inherited from ``legend_key_size``.
|
|
217
|
+
legend_key_height : float
|
|
218
|
+
Key background height, inherited from ``legend_key_size``.
|
|
219
|
+
legend_key_spacing : float
|
|
220
|
+
Spacing between legend keys.
|
|
221
|
+
legend_key_spacing_x : float
|
|
222
|
+
Spacing between legend keys in the horizontal direction, inherited from ``legend_key_spacing``.
|
|
223
|
+
legend_key_spacing_y : float
|
|
224
|
+
Spacing between legend keys in the vertical direction, inherited from ``legend_key_spacing``.
|
|
225
|
+
legend_box : {'horizontal', 'vertical'}
|
|
226
|
+
Arrangement of multiple legends.
|
|
227
|
+
legend_box_just : {'left', 'right', 'bottom', 'top', 'center'}
|
|
228
|
+
Justification of each legend within the overall bounding box, when there are multiple legends.
|
|
229
|
+
legend_box_spacing : float
|
|
230
|
+
Spacing between plotting area and legend box.
|
|
231
|
+
legend_ticks : str or dict
|
|
232
|
+
Style settings for tick marks in colorbars.
|
|
233
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
234
|
+
Set `element_line() <https://lets-plot.org/python/pages/api/lets_plot.element_line.html>`__ to specify all tick mark parameters.
|
|
235
|
+
``legend_ticks_*`` DOES NOT inherit from ``line``.
|
|
236
|
+
By default, the colorbar tick marks are drawn with the same color as the colorbar background.
|
|
237
|
+
legend_ticks_length : float
|
|
238
|
+
Length of colorbar tick marks in px.
|
|
239
|
+
panel_background : str or dict
|
|
240
|
+
Style settings for background of plotting area.
|
|
241
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
242
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify plotting area background parameters, inherited from ``rect``.
|
|
243
|
+
panel_border : str or dict
|
|
244
|
+
Style settings for border around plotting area.
|
|
245
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
246
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify border parameters, inherited from ``rect``.
|
|
247
|
+
panel_border_ontop : bool, default=True
|
|
248
|
+
Option to place border around plotting area over the data layers.
|
|
249
|
+
panel_grid, panel_grid_major, panel_grid_minor, panel_grid_major_x, panel_grid_major_y, panel_grid_minor_x, panel_grid_minor_y : str or dict
|
|
250
|
+
Style settings for grid lines. Specify major grid lines or minor grid lines separately if needed.
|
|
251
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
252
|
+
Set `element_line() <https://lets-plot.org/python/pages/api/lets_plot.element_line.html>`__ to specify grid line parameters.
|
|
253
|
+
``panel_grid_*_*`` inherits from ``panel_grid_*`` which inherits from ``panel_grid``,
|
|
254
|
+
which in turn inherits from ``line``.
|
|
255
|
+
panel_inset : number or list of numbers
|
|
256
|
+
Inset for a panel. The inset behaves like a padding for ``coord_polar(transform_bkgr=False)`` otherwise it behaves like a margin around the panel.
|
|
257
|
+
The inset may be specified using a number or a list of numbers:
|
|
258
|
+
|
|
259
|
+
- a number or list of one number - the same inset is applied to all four sides;
|
|
260
|
+
- a list of two numbers - the first inset applies to the top and bottom, the second - to the left and right;
|
|
261
|
+
- a list of three numbers - the first inset applies to the top, the second - to the right and left, the third - to the bottom;
|
|
262
|
+
- a list of four numbers - the insets are applied to the top, right, bottom and left in that order.
|
|
263
|
+
|
|
264
|
+
It is acceptable to use None for any side; in this case, the default value for the panel inset side will be used.
|
|
265
|
+
panel_grid_ontop, panel_grid_ontop_x, panel_grid_ontop_y : bool, default=False
|
|
266
|
+
Option to place major grid lines and minor grid lines over the data layers.
|
|
267
|
+
plot_background : str or dict
|
|
268
|
+
Style settings for overall plot background.
|
|
269
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
270
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify plot background parameters, inherited from ``rect``.
|
|
271
|
+
plot_title : str or dict
|
|
272
|
+
Style settings for plot title.
|
|
273
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
274
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify plot title parameters, inherited from ``title``.
|
|
275
|
+
plot_subtitle : str or dict
|
|
276
|
+
Style settings for plot subtitle.
|
|
277
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
278
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify plot subtitle parameters, inherited from ``plot_title`` or ``title``.
|
|
279
|
+
plot_caption : str or dict
|
|
280
|
+
Style settings for plot caption.
|
|
281
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
282
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify plot caption parameters, inherited from ``title``.
|
|
283
|
+
plot_message : str or dict
|
|
284
|
+
Style settings for plot message (e.g. sampling messages).
|
|
285
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to show nothing.
|
|
286
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to show sampling messages (`element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ options don't affect a message text).
|
|
287
|
+
plot_margin : number or list of numbers
|
|
288
|
+
Margin around entire plot.
|
|
289
|
+
The margin may be specified using a number or a list of numbers:
|
|
290
|
+
|
|
291
|
+
- a number or list of one number - the same margin is applied to all four sides;
|
|
292
|
+
- a list of two numbers - the first margin applies to the top and bottom, the second - to the left and right;
|
|
293
|
+
- a list of three numbers - the first margin applies to the top, the second - to the right and left, the third - to the bottom;
|
|
294
|
+
- a list of four numbers - the margins are applied to the top, right, bottom and left in that order.
|
|
295
|
+
|
|
296
|
+
It is acceptable to use None for any side; in this case, the default value for the plot margin side will be used.
|
|
297
|
+
plot_inset : number or list of numbers
|
|
298
|
+
Inset for a plotting area, including the axes with their labels, but without titles.
|
|
299
|
+
The inset may be specified using a number or a list of numbers:
|
|
300
|
+
|
|
301
|
+
- a number or list of one number - the same inset is applied to all four sides;
|
|
302
|
+
- a list of two numbers - the first inset applies to the top and bottom, the second - to the left and right;
|
|
303
|
+
- a list of three numbers - the first inset applies to the top, the second - to the right and left, the third - to the bottom;
|
|
304
|
+
- a list of four numbers - the insets are applied to the top, right, bottom and left in that order.
|
|
305
|
+
|
|
306
|
+
It is acceptable to use None for any side; in this case, the default value for the plot inset side will be used.
|
|
307
|
+
plot_title_position : {'panel', 'plot'}, default='panel'
|
|
308
|
+
Alignment of the plot title/subtitle.
|
|
309
|
+
A value of 'panel' means that title and subtitle are aligned to the plot panels.
|
|
310
|
+
A value of 'plot' means that title and subtitle are aligned to the entire plot (excluding margins).
|
|
311
|
+
plot_caption_position : {'panel', 'plot'}, default='panel'
|
|
312
|
+
Alignment of the plot caption.
|
|
313
|
+
A value of 'panel' means that caption is aligned to the plot panels.
|
|
314
|
+
A value of 'plot' means that caption is aligned to the entire plot (excluding margins).
|
|
315
|
+
strip_background : str or dict
|
|
316
|
+
Style settings for facet strip background.
|
|
317
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
318
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify facet label background parameters, inherited from ``rect``.
|
|
319
|
+
strip_background_x : str or dict
|
|
320
|
+
Style settings for horizontal facet background.
|
|
321
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
322
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify facet label background parameters, inherited from ``strip_background``.
|
|
323
|
+
strip_background_y : str or dict
|
|
324
|
+
Style settings for vertical facet background.
|
|
325
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing.
|
|
326
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify facet label background parameters, inherited from ``strip_background``.
|
|
327
|
+
strip_text : str or dict
|
|
328
|
+
Style settings for facet labels.
|
|
329
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
330
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify facet label parameters, inherited from ``text``.
|
|
331
|
+
strip_text_x : str or dict
|
|
332
|
+
Style settings for horizontal facet labels.
|
|
333
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
334
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify facet label parameters, inherited from ``strip_text``.
|
|
335
|
+
strip_text_y : str or dict
|
|
336
|
+
Style settings for vertical facet labels.
|
|
337
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
338
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify facet label parameters, inherited from ``strip_text``.
|
|
339
|
+
strip_spacing : float
|
|
340
|
+
Spacing between facet labels and the plotting area.
|
|
341
|
+
strip_spacing_x : float
|
|
342
|
+
Spacing between facet labels and the plotting area in horizontal direction, inherited from ``strip_spacing``.
|
|
343
|
+
strip_spacing_y : float
|
|
344
|
+
Spacing between facet labels and the plotting area in vertical direction, inherited from ``strip_spacing``.
|
|
345
|
+
panel_spacing : float
|
|
346
|
+
Spacing between panels in facets.
|
|
347
|
+
panel_spacing_x : float
|
|
348
|
+
Spacing between panels in facets in horizontal direction, inherited from ``panel_spacing``.
|
|
349
|
+
panel_spacing_y : float
|
|
350
|
+
Spacing between panels in facets in vertical direction, inherited from ``panel_spacing``.
|
|
351
|
+
axis_tooltip, axis_tooltip_x, axis_tooltip_y : str or dict
|
|
352
|
+
Style settings for axes tooltips.
|
|
353
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
354
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify axes tooltip parameters.
|
|
355
|
+
``axis_tooltip_*`` inherits from ``axis_tooltip`` which inherits from ``rect``.
|
|
356
|
+
axis_tooltip_text, axis_tooltip_text_x, axis_tooltip_text_y : str or dict
|
|
357
|
+
Style settings for text in axes tooltips.
|
|
358
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to draw nothing and assign no space.
|
|
359
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify axes text tooltip parameters.
|
|
360
|
+
``axis_tooltip_text_*`` inherits from ``axis_tooltip_text`` which inherits from ``tooltip_text``.
|
|
361
|
+
tooltip : str or dict
|
|
362
|
+
Style settings for general tooltip.
|
|
363
|
+
Set 'blank' or result of `element_blank() <https://lets-plot.org/python/pages/api/lets_plot.element_blank.html>`__ to hide the tooltip (also hides side tooltips).
|
|
364
|
+
Set `element_rect() <https://lets-plot.org/python/pages/api/lets_plot.element_rect.html>`__ to specify tooltip rectangular parameters, inherited from ``rect``.
|
|
365
|
+
tooltip_text : dict
|
|
366
|
+
Style settings for text in general tooltip.
|
|
367
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify tooltip text parameters.
|
|
368
|
+
tooltip_title_text : dict
|
|
369
|
+
Style settings for tooltip title text.
|
|
370
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify tooltip title parameters, inherited from ``tooltip_text``. Bold by default.
|
|
371
|
+
label_text : dict
|
|
372
|
+
Style settings for annotation text.
|
|
373
|
+
Annotations are currently supported for pie, bar chart and crossbar.
|
|
374
|
+
Set `element_text() <https://lets-plot.org/python/pages/api/lets_plot.element_text.html>`__ to specify annotation text parameters: font family and face, text size, text color.
|
|
375
|
+
geom : dict
|
|
376
|
+
Color settings for geometries.
|
|
377
|
+
Set `element_geom() <https://lets-plot.org/python/pages/api/lets_plot.element_geom.html>`__ to specify new values for the named colors.
|
|
378
|
+
|
|
379
|
+
Returns
|
|
380
|
+
-------
|
|
381
|
+
``FeatureSpec``
|
|
382
|
+
Theme specification.
|
|
383
|
+
|
|
384
|
+
Examples
|
|
385
|
+
--------
|
|
386
|
+
.. jupyter-execute::
|
|
387
|
+
:linenos:
|
|
388
|
+
:emphasize-lines: 11-16
|
|
389
|
+
|
|
390
|
+
import numpy as np
|
|
391
|
+
from lets_plot import *
|
|
392
|
+
LetsPlot.setup_html()
|
|
393
|
+
n = 100
|
|
394
|
+
np.random.seed(42)
|
|
395
|
+
x = np.random.normal(size=n)
|
|
396
|
+
c = np.random.choice(['a', 'b', 'c'], size=n)
|
|
397
|
+
ggplot({'x': x, 'class': c}, aes('x')) + \\
|
|
398
|
+
geom_density(aes(color='class'), size=2) + \\
|
|
399
|
+
ggtitle('Density of classes') + \\
|
|
400
|
+
theme(axis_line=element_line(size=4), \\
|
|
401
|
+
axis_ticks_length=10, \\
|
|
402
|
+
axis_title_y='blank', \\
|
|
403
|
+
legend_position=[1, 1], legend_justification=[1, 1], \\
|
|
404
|
+
panel_background=element_rect(color='black', fill='#eeeeee', size=2), \\
|
|
405
|
+
panel_grid=element_line(color='black', size=1))
|
|
406
|
+
|
|
407
|
+
|
|
|
408
|
+
|
|
409
|
+
.. jupyter-execute::
|
|
410
|
+
:linenos:
|
|
411
|
+
:emphasize-lines: 14-19
|
|
412
|
+
|
|
413
|
+
import numpy as np
|
|
414
|
+
from lets_plot import *
|
|
415
|
+
LetsPlot.setup_html()
|
|
416
|
+
n = 1000
|
|
417
|
+
np.random.seed(42)
|
|
418
|
+
p = np.random.uniform(size=7)
|
|
419
|
+
x = np.random.choice(range(p.size), p=p/p.sum(), size=n)
|
|
420
|
+
c = np.random.choice(['a', 'b', 'c'], p=[.5, .3, .2], size=n)
|
|
421
|
+
ggplot({'x': x, 'class': c}) + \\
|
|
422
|
+
geom_bar(aes('x', fill='x')) + \\
|
|
423
|
+
scale_y_continuous(breaks=list(range(0, 151, 25))) + \\
|
|
424
|
+
scale_fill_discrete() + \\
|
|
425
|
+
facet_grid(y='class') + \\
|
|
426
|
+
theme(axis_line_x='blank', \\
|
|
427
|
+
axis_ticks=element_line(color='white'), \\
|
|
428
|
+
panel_grid_major_x='blank', \\
|
|
429
|
+
strip_background=element_rect(color='black', fill='white'), \\
|
|
430
|
+
axis_tooltip=element_rect(color='black', fill='white'), \\
|
|
431
|
+
legend_position='top')
|
|
432
|
+
|
|
433
|
+
"""
|
|
434
|
+
|
|
435
|
+
filtered = _filter_none(locals())
|
|
436
|
+
return FeatureSpec('theme', name=None, **filtered)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
def _filter_none(original: dict) -> dict:
|
|
440
|
+
def _filter_val(value):
|
|
441
|
+
if isinstance(value, dict):
|
|
442
|
+
return _filter_none(value)
|
|
443
|
+
else:
|
|
444
|
+
return value
|
|
445
|
+
|
|
446
|
+
return {k: _filter_val(v) for k, v in original.items() if v is not None}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def element_blank() -> dict:
|
|
450
|
+
"""
|
|
451
|
+
Theme element that draws nothing and allocates no space for non-data components of the plot.
|
|
452
|
+
|
|
453
|
+
Returns
|
|
454
|
+
-------
|
|
455
|
+
``dict``
|
|
456
|
+
Theme element specification.
|
|
457
|
+
|
|
458
|
+
Examples
|
|
459
|
+
--------
|
|
460
|
+
.. jupyter-execute::
|
|
461
|
+
:linenos:
|
|
462
|
+
:emphasize-lines: 7
|
|
463
|
+
|
|
464
|
+
import numpy as np
|
|
465
|
+
from lets_plot import *
|
|
466
|
+
LetsPlot.setup_html()
|
|
467
|
+
np.random.seed(42)
|
|
468
|
+
data = {'x': np.random.normal(size=1000)}
|
|
469
|
+
ggplot(data, aes(x='x')) + geom_histogram() + \\
|
|
470
|
+
theme(axis_title_x=element_blank(), axis_ticks=element_blank())
|
|
471
|
+
|
|
472
|
+
"""
|
|
473
|
+
return dict(blank=True)
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def element_rect(
|
|
477
|
+
fill=None,
|
|
478
|
+
color=None,
|
|
479
|
+
size=None,
|
|
480
|
+
linetype=None,
|
|
481
|
+
blank=False,
|
|
482
|
+
) -> dict:
|
|
483
|
+
"""
|
|
484
|
+
Theme element that draws rectangular non-data components of the plot: borders and backgrounds.
|
|
485
|
+
|
|
486
|
+
Parameters
|
|
487
|
+
----------
|
|
488
|
+
fill : str
|
|
489
|
+
Fill color.
|
|
490
|
+
color : str
|
|
491
|
+
Border color.
|
|
492
|
+
size : int
|
|
493
|
+
Border size.
|
|
494
|
+
linetype : int or str or list
|
|
495
|
+
Type of the line. Accepts the following values:
|
|
496
|
+
|
|
497
|
+
- Codes or names: 0 = 'blank', 1 = 'solid', 2 = 'dashed', 3 = 'dotted', 4 = 'dotdash', 5 = 'longdash', 6 = 'twodash'.
|
|
498
|
+
- A string of an even number (up to eight) of hexadecimal digits, specifying the lengths in consecutive positions.
|
|
499
|
+
- A list defines the pattern of dashes and gaps, either with an offset: [offset, [dash, gap, ...]], or without an offset: [dash, gap, ...].
|
|
500
|
+
|
|
501
|
+
For more info see `Line Types <https://lets-plot.org/python/pages/aesthetics.html#line-types>`__.
|
|
502
|
+
blank : bool, default=False
|
|
503
|
+
If True - draws nothing, and assigns no space.
|
|
504
|
+
|
|
505
|
+
Returns
|
|
506
|
+
-------
|
|
507
|
+
``dict``
|
|
508
|
+
Theme element specification.
|
|
509
|
+
|
|
510
|
+
Examples
|
|
511
|
+
--------
|
|
512
|
+
.. jupyter-execute::
|
|
513
|
+
:linenos:
|
|
514
|
+
:emphasize-lines: 7
|
|
515
|
+
|
|
516
|
+
import numpy as np
|
|
517
|
+
from lets_plot import *
|
|
518
|
+
LetsPlot.setup_html()
|
|
519
|
+
np.random.seed(42)
|
|
520
|
+
data = {'x': np.random.normal(size=1000)}
|
|
521
|
+
ggplot(data, aes(x='x')) + geom_histogram() + \\
|
|
522
|
+
theme(panel_background=element_rect(fill='#f7fcf5'))
|
|
523
|
+
|
|
524
|
+
"""
|
|
525
|
+
return locals()
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def element_line(
|
|
529
|
+
color=None,
|
|
530
|
+
size=None,
|
|
531
|
+
linetype=None,
|
|
532
|
+
# ToDo: lineend, arrow
|
|
533
|
+
blank=False,
|
|
534
|
+
) -> dict:
|
|
535
|
+
"""
|
|
536
|
+
Theme element that draws line-based non-data components of the plot.
|
|
537
|
+
|
|
538
|
+
Parameters
|
|
539
|
+
----------
|
|
540
|
+
color : str
|
|
541
|
+
Line color.
|
|
542
|
+
size : int
|
|
543
|
+
Line size.
|
|
544
|
+
linetype : int or str or list
|
|
545
|
+
Type of the line. Accepts the following values:
|
|
546
|
+
|
|
547
|
+
- Codes or names: 0 = 'blank', 1 = 'solid', 2 = 'dashed', 3 = 'dotted', 4 = 'dotdash', 5 = 'longdash', 6 = 'twodash'.
|
|
548
|
+
- A string of an even number (up to eight) of hexadecimal digits, specifying the lengths in consecutive positions.
|
|
549
|
+
- A list defines the pattern of dashes and gaps, either with an offset: [offset, [dash, gap, ...]], or without an offset: [dash, gap, ...].
|
|
550
|
+
|
|
551
|
+
For more info see `Line Types <https://lets-plot.org/python/pages/aesthetics.html#line-types>`__.
|
|
552
|
+
blank : bool, default=False
|
|
553
|
+
If True - draws nothing, and assigns no space.
|
|
554
|
+
|
|
555
|
+
Returns
|
|
556
|
+
-------
|
|
557
|
+
``dict``
|
|
558
|
+
Theme element specification.
|
|
559
|
+
|
|
560
|
+
Examples
|
|
561
|
+
--------
|
|
562
|
+
.. jupyter-execute::
|
|
563
|
+
:linenos:
|
|
564
|
+
:emphasize-lines: 7
|
|
565
|
+
|
|
566
|
+
import numpy as np
|
|
567
|
+
from lets_plot import *
|
|
568
|
+
LetsPlot.setup_html()
|
|
569
|
+
np.random.seed(42)
|
|
570
|
+
data = {'x': np.random.normal(size=1000)}
|
|
571
|
+
ggplot(data, aes(x='x')) + geom_histogram() + \\
|
|
572
|
+
theme(panel_grid=element_line(size=3, linetype='dashed'))
|
|
573
|
+
|
|
574
|
+
"""
|
|
575
|
+
return locals()
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
def element_text(
|
|
579
|
+
color=None,
|
|
580
|
+
family=None,
|
|
581
|
+
face=None,
|
|
582
|
+
size=None,
|
|
583
|
+
angle=None,
|
|
584
|
+
# ToDo: lineheight
|
|
585
|
+
hjust=None,
|
|
586
|
+
vjust=None,
|
|
587
|
+
margin=None,
|
|
588
|
+
blank=False,
|
|
589
|
+
) -> dict:
|
|
590
|
+
"""
|
|
591
|
+
Theme element that draws text for non-data components of the plot.
|
|
592
|
+
|
|
593
|
+
Parameters
|
|
594
|
+
----------
|
|
595
|
+
color : str
|
|
596
|
+
Text color.
|
|
597
|
+
family : str
|
|
598
|
+
Font family.
|
|
599
|
+
face : str
|
|
600
|
+
Font face ("plain", "italic", "bold", "bold_italic").
|
|
601
|
+
size : int
|
|
602
|
+
Text size in px.
|
|
603
|
+
angle : float
|
|
604
|
+
Angle to rotate the text (in degrees).
|
|
605
|
+
hjust : float
|
|
606
|
+
Horizontal justification (in [0, 1]).
|
|
607
|
+
0 - left-justified;
|
|
608
|
+
1 - right-justified;
|
|
609
|
+
0.5 - center-justified.
|
|
610
|
+
Values outside the [0, 1] range are allowed but may produce unpredictable results.
|
|
611
|
+
vjust : float
|
|
612
|
+
Vertical justification (in [0, 1]).
|
|
613
|
+
0 - bottom-justified;
|
|
614
|
+
1 - top-justified;
|
|
615
|
+
0.5 - middle-justified.
|
|
616
|
+
Values outside the [0, 1] range are allowed but may produce unpredictable results.
|
|
617
|
+
margin : number or list of numbers
|
|
618
|
+
Margins around the text.
|
|
619
|
+
The margin may be specified using a number or a list of numbers:
|
|
620
|
+
|
|
621
|
+
- a number or list of one number - the same margin is applied to all four sides;
|
|
622
|
+
- a list of two numbers - the first margin applies to the top and bottom, the second - to the left and right;
|
|
623
|
+
- a list of three numbers - the first margin applies to the top, the second - to the right and left, the third - to the bottom;
|
|
624
|
+
- a list of four numbers - the margins are applied to the top, right, bottom and left in that order.
|
|
625
|
+
|
|
626
|
+
It is acceptable to use None for any side; in this case, the default side value for this element will be used.
|
|
627
|
+
blank : bool, default=False
|
|
628
|
+
If True - draws nothing, and assigns no space.
|
|
629
|
+
|
|
630
|
+
Returns
|
|
631
|
+
-------
|
|
632
|
+
``dict``
|
|
633
|
+
Theme element specification.
|
|
634
|
+
|
|
635
|
+
Examples
|
|
636
|
+
--------
|
|
637
|
+
.. jupyter-execute::
|
|
638
|
+
:linenos:
|
|
639
|
+
:emphasize-lines: 7
|
|
640
|
+
|
|
641
|
+
import numpy as np
|
|
642
|
+
from lets_plot import *
|
|
643
|
+
LetsPlot.setup_html()
|
|
644
|
+
np.random.seed(42)
|
|
645
|
+
data = {'x': np.random.normal(size=1000)}
|
|
646
|
+
ggplot(data, aes(x='x')) + geom_histogram() + \\
|
|
647
|
+
theme(axis_text=element_text(color='#cb181d', face='bold_italic'))
|
|
648
|
+
|
|
649
|
+
"""
|
|
650
|
+
return locals()
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
def element_markdown(
|
|
654
|
+
color=None,
|
|
655
|
+
family=None,
|
|
656
|
+
face=None,
|
|
657
|
+
size=None,
|
|
658
|
+
angle=None,
|
|
659
|
+
# ToDo: lineheight
|
|
660
|
+
hjust=None,
|
|
661
|
+
vjust=None,
|
|
662
|
+
margin=None,
|
|
663
|
+
blank=False,
|
|
664
|
+
) -> dict:
|
|
665
|
+
"""
|
|
666
|
+
Theme element that draws text with Markdown support for non-data components of the plot.
|
|
667
|
+
|
|
668
|
+
Supported features:
|
|
669
|
+
|
|
670
|
+
- Emphasis (\*, \*\*, \*\*\*, _, __, ___)
|
|
671
|
+
- Coloring with inline style (<span style='color:red'>text</span>)
|
|
672
|
+
- Links with anchor tags (<a href="https://lets-plot.org">Lets-Plot</a>). Supports target attribute (default is "_blank")
|
|
673
|
+
- Multiple lines using double space and a newline delimiter ( ``\\n``)
|
|
674
|
+
|
|
675
|
+
Parameters
|
|
676
|
+
----------
|
|
677
|
+
color : str
|
|
678
|
+
Text color.
|
|
679
|
+
family : str
|
|
680
|
+
Font family.
|
|
681
|
+
face : {'plain', 'italic', 'bold', 'bold_italic'}, default='plain'
|
|
682
|
+
Font face.
|
|
683
|
+
size : int
|
|
684
|
+
Text size in px.
|
|
685
|
+
angle : float
|
|
686
|
+
Angle to rotate the text (in degrees).
|
|
687
|
+
hjust : float
|
|
688
|
+
Horizontal justification (in [0, 1]).
|
|
689
|
+
0 - left-justified;
|
|
690
|
+
1 - right-justified;
|
|
691
|
+
0.5 - center-justified.
|
|
692
|
+
Can be used with values out of range, but behaviour is not specified.
|
|
693
|
+
vjust : float
|
|
694
|
+
Vertical justification (in [0, 1]).
|
|
695
|
+
0 - bottom-justified;
|
|
696
|
+
1 - top-justified;
|
|
697
|
+
0.5 - middle-justified.
|
|
698
|
+
Can be used with values out of range, but behaviour is not specified.
|
|
699
|
+
margin : number or list of numbers
|
|
700
|
+
Margins around the text.
|
|
701
|
+
The margin may be specified using a number or a list of numbers:
|
|
702
|
+
|
|
703
|
+
- a number or list of one number - the same margin is applied to all four sides;
|
|
704
|
+
- a list of two numbers - the first margin applies to the top and bottom, the second - to the left and right;
|
|
705
|
+
- a list of three numbers - the first margin applies to the top, the second - to the right and left, the third - to the bottom;
|
|
706
|
+
- a list of four numbers - the margins are applied to the top, right, bottom and left in that order.
|
|
707
|
+
|
|
708
|
+
It is acceptable to use None for any side; in this case, the default side value for this element will be used.
|
|
709
|
+
blank : bool, default=False
|
|
710
|
+
If True - draws nothing, and assigns no space.
|
|
711
|
+
|
|
712
|
+
Returns
|
|
713
|
+
-------
|
|
714
|
+
``dict``
|
|
715
|
+
Theme element specification.
|
|
716
|
+
|
|
717
|
+
Examples
|
|
718
|
+
--------
|
|
719
|
+
.. jupyter-execute::
|
|
720
|
+
:linenos:
|
|
721
|
+
:emphasize-lines: 12
|
|
722
|
+
|
|
723
|
+
from lets_plot import *
|
|
724
|
+
LetsPlot.setup_html()
|
|
725
|
+
ggplot() + \\
|
|
726
|
+
geom_blank() + \\
|
|
727
|
+
labs(
|
|
728
|
+
title='*Hello*, **world**',
|
|
729
|
+
subtitle='_Simple plot_',
|
|
730
|
+
caption='*Powered by **lets-plot***',
|
|
731
|
+
x='Title **X**',
|
|
732
|
+
y='Title **Y**'
|
|
733
|
+
) + \\
|
|
734
|
+
theme(title=element_markdown())
|
|
735
|
+
|
|
736
|
+
"""
|
|
737
|
+
return {'markdown': True, **locals()}
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
def margin(t=None, r=None, b=None, l=None):
|
|
741
|
+
"""
|
|
742
|
+
Function ``margin()`` is deprecated.
|
|
743
|
+
Please, use a number or list of numbers to specify margins (see description of the parameter used).
|
|
744
|
+
|
|
745
|
+
"""
|
|
746
|
+
print("WARN: The margin() is deprecated and will be removed in future releases.\n"
|
|
747
|
+
" Please, use a number or list of numbers to specify margins (see description of the parameter used).")
|
|
748
|
+
|
|
749
|
+
return [t, r, b, l]
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
def element_geom(
|
|
753
|
+
pen=None,
|
|
754
|
+
brush=None,
|
|
755
|
+
paper=None,
|
|
756
|
+
# ToDo: fatten
|
|
757
|
+
) -> dict:
|
|
758
|
+
"""
|
|
759
|
+
Theme element that specifies custom values for named geom colors used in plot elements.
|
|
760
|
+
|
|
761
|
+
Parameters
|
|
762
|
+
----------
|
|
763
|
+
pen : str
|
|
764
|
+
Color to use by name "pen".
|
|
765
|
+
brush : str
|
|
766
|
+
Color to use by name "brush".
|
|
767
|
+
paper : str
|
|
768
|
+
Color to use by name "paper".
|
|
769
|
+
|
|
770
|
+
Returns
|
|
771
|
+
-------
|
|
772
|
+
``dict``
|
|
773
|
+
Theme element specification.
|
|
774
|
+
|
|
775
|
+
Examples
|
|
776
|
+
--------
|
|
777
|
+
.. jupyter-execute::
|
|
778
|
+
:linenos:
|
|
779
|
+
:emphasize-lines: 7
|
|
780
|
+
|
|
781
|
+
import numpy as np
|
|
782
|
+
from lets_plot import *
|
|
783
|
+
LetsPlot.setup_html()
|
|
784
|
+
np.random.seed(42)
|
|
785
|
+
data = {'x': np.random.normal(size=1000)}
|
|
786
|
+
ggplot(data, aes(x='x')) + geom_histogram(color='pen', fill='paper') + \\
|
|
787
|
+
theme(geom=element_geom(pen='dark_blue', paper='light_blue'))
|
|
788
|
+
|
|
789
|
+
"""
|
|
790
|
+
return locals()
|