lets-plot 4.5.0__cp313-cp313-macosx_10_15_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.

Potentially problematic release.


This version of lets-plot might be problematic. Click here for more details.

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