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.
Files changed (97) hide show
  1. lets_plot/__init__.py +382 -0
  2. lets_plot/_global_settings.py +192 -0
  3. lets_plot/_kbridge.py +197 -0
  4. lets_plot/_type_utils.py +133 -0
  5. lets_plot/_version.py +6 -0
  6. lets_plot/bistro/__init__.py +16 -0
  7. lets_plot/bistro/_plot2d_common.py +106 -0
  8. lets_plot/bistro/corr.py +448 -0
  9. lets_plot/bistro/im.py +196 -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 +332 -0
  14. lets_plot/export/__init__.py +6 -0
  15. lets_plot/export/ggsave_.py +172 -0
  16. lets_plot/frontend_context/__init__.py +8 -0
  17. lets_plot/frontend_context/_configuration.py +140 -0
  18. lets_plot/frontend_context/_dynamic_configure_html.py +115 -0
  19. lets_plot/frontend_context/_frontend_ctx.py +16 -0
  20. lets_plot/frontend_context/_html_contexts.py +223 -0
  21. lets_plot/frontend_context/_intellij_python_json_ctx.py +38 -0
  22. lets_plot/frontend_context/_isolated_webview_panel_ctx.py +81 -0
  23. lets_plot/frontend_context/_json_contexts.py +39 -0
  24. lets_plot/frontend_context/_jupyter_notebook_ctx.py +82 -0
  25. lets_plot/frontend_context/_mime_types.py +7 -0
  26. lets_plot/frontend_context/_static_html_page_ctx.py +76 -0
  27. lets_plot/frontend_context/_static_svg_ctx.py +26 -0
  28. lets_plot/frontend_context/_webbr_html_page_ctx.py +29 -0
  29. lets_plot/frontend_context/sandbox.py +5 -0
  30. lets_plot/geo_data/__init__.py +19 -0
  31. lets_plot/geo_data/core.py +335 -0
  32. lets_plot/geo_data/geocoder.py +988 -0
  33. lets_plot/geo_data/geocodes.py +512 -0
  34. lets_plot/geo_data/gis/__init__.py +0 -0
  35. lets_plot/geo_data/gis/fluent_dict.py +201 -0
  36. lets_plot/geo_data/gis/geocoding_service.py +42 -0
  37. lets_plot/geo_data/gis/geometry.py +91 -0
  38. lets_plot/geo_data/gis/json_request.py +232 -0
  39. lets_plot/geo_data/gis/json_response.py +308 -0
  40. lets_plot/geo_data/gis/request.py +492 -0
  41. lets_plot/geo_data/gis/response.py +247 -0
  42. lets_plot/geo_data/livemap_helper.py +65 -0
  43. lets_plot/geo_data/to_geo_data_frame.py +141 -0
  44. lets_plot/geo_data/type_assertion.py +34 -0
  45. lets_plot/geo_data_internals/__init__.py +4 -0
  46. lets_plot/geo_data_internals/constants.py +13 -0
  47. lets_plot/geo_data_internals/utils.py +33 -0
  48. lets_plot/mapping.py +115 -0
  49. lets_plot/package_data/lets-plot.min.js +3 -0
  50. lets_plot/plot/__init__.py +64 -0
  51. lets_plot/plot/_global_theme.py +14 -0
  52. lets_plot/plot/annotation.py +290 -0
  53. lets_plot/plot/coord.py +242 -0
  54. lets_plot/plot/core.py +1071 -0
  55. lets_plot/plot/expand_limits_.py +78 -0
  56. lets_plot/plot/facet.py +210 -0
  57. lets_plot/plot/font_features.py +71 -0
  58. lets_plot/plot/geom.py +9146 -0
  59. lets_plot/plot/geom_extras.py +53 -0
  60. lets_plot/plot/geom_function_.py +219 -0
  61. lets_plot/plot/geom_imshow_.py +393 -0
  62. lets_plot/plot/geom_livemap_.py +343 -0
  63. lets_plot/plot/ggbunch_.py +96 -0
  64. lets_plot/plot/gggrid_.py +139 -0
  65. lets_plot/plot/ggtb_.py +81 -0
  66. lets_plot/plot/guide.py +231 -0
  67. lets_plot/plot/label.py +187 -0
  68. lets_plot/plot/marginal_layer.py +181 -0
  69. lets_plot/plot/plot.py +245 -0
  70. lets_plot/plot/pos.py +344 -0
  71. lets_plot/plot/sampling.py +338 -0
  72. lets_plot/plot/sandbox_.py +26 -0
  73. lets_plot/plot/scale.py +3580 -0
  74. lets_plot/plot/scale_colormap_mpl.py +300 -0
  75. lets_plot/plot/scale_convenience.py +155 -0
  76. lets_plot/plot/scale_identity_.py +653 -0
  77. lets_plot/plot/scale_position.py +1342 -0
  78. lets_plot/plot/series_meta.py +209 -0
  79. lets_plot/plot/stat.py +585 -0
  80. lets_plot/plot/subplots.py +331 -0
  81. lets_plot/plot/subplots_util.py +24 -0
  82. lets_plot/plot/theme_.py +790 -0
  83. lets_plot/plot/theme_set.py +418 -0
  84. lets_plot/plot/tooltip.py +486 -0
  85. lets_plot/plot/util.py +267 -0
  86. lets_plot/settings_utils.py +244 -0
  87. lets_plot/tilesets.py +429 -0
  88. lets_plot-4.8.1rc1.dist-info/METADATA +221 -0
  89. lets_plot-4.8.1rc1.dist-info/RECORD +97 -0
  90. lets_plot-4.8.1rc1.dist-info/WHEEL +6 -0
  91. lets_plot-4.8.1rc1.dist-info/licenses/LICENSE +21 -0
  92. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.FreeType +166 -0
  93. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.ImageMagick +106 -0
  94. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.expat +21 -0
  95. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.fontconfig +200 -0
  96. lets_plot-4.8.1rc1.dist-info/top_level.txt +2 -0
  97. lets_plot_kotlin_bridge.cpython-311-x86_64-linux-gnu.so +0 -0
@@ -0,0 +1,331 @@
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
+
6
+ # noinspection PyUnresolvedReferences
7
+ from typing import Dict
8
+
9
+ from lets_plot.plot.core import DummySpec
10
+ from lets_plot.plot.core import FeatureSpec
11
+ from lets_plot.plot.core import FeatureSpecArray
12
+ from lets_plot.plot.core import _specs_to_dict
13
+ from lets_plot.plot.core import _theme_dicts_merge
14
+ from lets_plot.plot.core import _to_svg, _to_html, _export_as_raster
15
+
16
+ __all__ = ['SupPlotsSpec']
17
+
18
+
19
+ class SupPlotsLayoutSpec:
20
+ """
21
+ Plots layout specification used in constructing subplots figure.
22
+ """
23
+
24
+ def __init__(self, name: str, **kwargs):
25
+ """Initialize self."""
26
+ self.__props = {}
27
+ self.__props.update(**kwargs)
28
+ self.__props['name'] = name
29
+
30
+ def as_dict(self) -> Dict:
31
+ return _specs_to_dict(self.__props)
32
+
33
+
34
+ class SupPlotsSpec(FeatureSpec):
35
+ """
36
+ Subplots figure specification.
37
+
38
+ See: `gggrid() <https://lets-plot.org/python/pages/api/lets_plot.gggrid.html>`__.
39
+ """
40
+
41
+ @classmethod
42
+ def duplicate(cls, other):
43
+ dup = SupPlotsSpec(
44
+ figures=other.__figures,
45
+ layout=other.__layout
46
+ )
47
+ dup.props().update(other.props())
48
+ return dup
49
+
50
+ def __init__(self, figures: list, layout: SupPlotsLayoutSpec):
51
+ """Initialize self."""
52
+ super().__init__('subplots', None)
53
+ self.__figures = list(figures)
54
+ self.__layout = layout
55
+
56
+ def __add__(self, other):
57
+ """
58
+ """
59
+
60
+ if isinstance(other, DummySpec):
61
+ # nothing
62
+ return self
63
+
64
+ elif isinstance(other, FeatureSpecArray):
65
+ supplots = SupPlotsSpec.duplicate(self)
66
+ for spec in other.elements():
67
+ supplots = supplots.__add__(spec)
68
+ return supplots
69
+
70
+ elif isinstance(other, FeatureSpec) and other.kind in ["ggsize", "theme", "ggtitle", "caption", "ggtoolbar"]:
71
+
72
+ supplots = SupPlotsSpec.duplicate(self)
73
+ # ToDo: duplication!
74
+ if other.kind == 'theme':
75
+ new_theme_options = {k: v for k, v in other.props().items() if v is not None}
76
+ if 'name' in new_theme_options:
77
+ # keep the previously specified flavor
78
+ if supplots.props().get('theme', {}).get('flavor', None) is not None:
79
+ new_theme_options.update({'flavor': supplots.props()['theme']['flavor']})
80
+
81
+ # pre-configured theme overrides existing theme altogether.
82
+ supplots.props()['theme'] = new_theme_options
83
+ else:
84
+ # merge themes
85
+ old_theme_options = supplots.props().get('theme', {})
86
+ supplots.props()['theme'] = _theme_dicts_merge(old_theme_options, new_theme_options)
87
+
88
+ return supplots
89
+
90
+ # add feature to properties
91
+ supplots.props()[other.kind] = other
92
+ return supplots
93
+
94
+ return super().__add__(other)
95
+
96
+ def as_dict(self):
97
+ d = super().as_dict()
98
+ d['kind'] = self.kind
99
+ d['layout'] = self.__layout.as_dict()
100
+ d['figures'] = [figure.as_dict() if figure is not None else None for figure in self.__figures]
101
+
102
+ return d
103
+
104
+ def _repr_html_(self):
105
+ """
106
+ Special method discovered and invoked by IPython.display.display.
107
+ """
108
+ from ..frontend_context._configuration import _as_html
109
+ return _as_html(self.as_dict())
110
+
111
+ def show(self):
112
+ """
113
+ Draw all plots currently in this 'bunch'.
114
+ """
115
+ from ..frontend_context._configuration import _display_plot
116
+ _display_plot(self)
117
+
118
+ def to_svg(self, path=None, w=None, h=None, unit=None) -> str:
119
+ """
120
+ Export the plot in SVG format.
121
+
122
+ Parameters
123
+ ----------
124
+ self : ``SupPlotsSpec``
125
+ Subplots specification to export.
126
+ path : str, file-like object, default=None
127
+ It can be a file path, file-like object, or None.
128
+ If a string is provided, the result will be exported to the file at that path.
129
+ If a file-like object is provided, the result will be exported to that object.
130
+ If None is provided, the result will be returned as a string.
131
+ w : float, default=None
132
+ Width of the output image in units.
133
+ h : float, default=None
134
+ Height of the output image in units.
135
+ unit : {'in', 'cm', 'mm', 'px'}, default='in'
136
+ Unit of the output image. One of: 'in', 'cm', 'mm' or 'px'.
137
+
138
+ Returns
139
+ -------
140
+ str
141
+ The result depends on the ``path`` parameter.
142
+ It can be the absolute path of the file,
143
+ SVG content as a string, or None if a file-like object is provided.
144
+
145
+ Examples
146
+ --------
147
+ .. jupyter-execute::
148
+ :linenos:
149
+ :emphasize-lines: 13
150
+
151
+ import numpy as np
152
+ import io
153
+ import os
154
+ from lets_plot import *
155
+ from IPython import display
156
+ LetsPlot.setup_html()
157
+ n = 60
158
+ np.random.seed(42)
159
+ x = np.random.choice(list('abcde'), size=n)
160
+ y = np.random.normal(size=n)
161
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
162
+ file_like = io.BytesIO()
163
+ p.to_svg(file_like)
164
+ display.SVG(file_like.getvalue())
165
+ """
166
+ return _to_svg(self, path, w=w, h=h, unit=unit)
167
+
168
+ def to_html(self, path=None, iframe: bool = None) -> str:
169
+ """
170
+ Export the plot in HTML format.
171
+
172
+ Parameters
173
+ ----------
174
+ self : ``SupPlotsSpec``
175
+ Subplots specification to export.
176
+ path : str, file-like object, default=None
177
+ It can be a file path, file-like object, or None.
178
+ If a string is provided, the result will be exported to the file at that path.
179
+ If a file-like object is provided, the result will be exported to that object.
180
+ If None is provided, the result will be returned as a string.
181
+ iframe : bool, default=False
182
+ Whether to wrap HTML page into a iFrame.
183
+
184
+ Returns
185
+ -------
186
+ str
187
+ The result depends on the ``path`` parameter.
188
+ It can be the absolute path of the file,
189
+ HTML content as a string, or None if a file-like object is provided.
190
+
191
+ Examples
192
+ --------
193
+ .. jupyter-execute::
194
+ :linenos:
195
+ :emphasize-lines: 12
196
+
197
+ import numpy as np
198
+ import io
199
+ import os
200
+ from lets_plot import *
201
+ LetsPlot.setup_html()
202
+ n = 60
203
+ np.random.seed(42)
204
+ x = np.random.choice(list('abcde'), size=n)
205
+ y = np.random.normal(size=n)
206
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
207
+ file_like = io.BytesIO()
208
+ p.to_html(file_like)
209
+ """
210
+ return _to_html(self, path, iframe)
211
+
212
+ def to_png(self, path, scale=None, w=None, h=None, unit=None, dpi=None) -> str:
213
+ """
214
+ Export all plots currently in this 'bunch' to a file or file-like object in PNG format.
215
+
216
+ Parameters
217
+ ----------
218
+ self : ``SupPlotsSpec``
219
+ Subplots specification to export.
220
+ path : str, file-like object
221
+ Сan be either a string specifying a file path or a file-like object.
222
+ If a string is provided, the result will be exported to the file at that path.
223
+ If a file-like object is provided, the result will be exported to that object.
224
+ scale : float
225
+ Scaling factor for raster output. Default value is 2.0.
226
+ w : float, default=None
227
+ Only applicable when exporting to PNG or PDF.
228
+ h : float, default=None
229
+ Height of the output image in units.
230
+ Only applicable when exporting to PNG or PDF.
231
+ unit : {'in', 'cm', 'mm', 'px'}, default='in'
232
+ Unit of the output image. One of: 'in', 'cm', 'mm' or 'px'.
233
+ Only applicable when exporting to PNG or PDF.
234
+ dpi : int, default=300
235
+ Resolution in dots per inch.
236
+ Only applicable when exporting to PNG or PDF.
237
+ The default value depends on the unit:
238
+
239
+ - for 'px' it is 96 (output image will have the same pixel size as ``w`` and ``h`` values)
240
+ - for physical units ('in', 'cm', 'mm') it is 300
241
+
242
+
243
+ Returns
244
+ -------
245
+ str
246
+ Absolute pathname of created file or None if a file-like object is provided.
247
+
248
+ Examples
249
+ --------
250
+ .. jupyter-execute::
251
+ :linenos:
252
+ :emphasize-lines: 13
253
+
254
+ import numpy as np
255
+ import io
256
+ import os
257
+ from lets_plot import *
258
+ from IPython import display
259
+ LetsPlot.setup_html()
260
+ n = 60
261
+ np.random.seed(42)
262
+ x = np.random.choice(list('abcde'), size=n)
263
+ y = np.random.normal(size=n)
264
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
265
+ file_like = io.BytesIO()
266
+ p.to_png(file_like)
267
+ display.Image(file_like.getvalue())
268
+ """
269
+ return _export_as_raster(self, path, scale, 'png', w=w, h=h, unit=unit, dpi=dpi)
270
+
271
+ def to_pdf(self, path, scale=None, w=None, h=None, unit=None, dpi=None) -> str:
272
+ """
273
+ Export all plots currently in this 'bunch' to a file or file-like object in PDF format.
274
+
275
+ Parameters
276
+ ----------
277
+ self : ``SupPlotsSpec``
278
+ Subplots specification to export.
279
+ path : str, file-like object
280
+ Сan be either a string specifying a file path or a file-like object.
281
+ If a string is provided, the result will be exported to the file at that path.
282
+ If a file-like object is provided, the result will be exported to that object.
283
+ scale : float
284
+ Scaling factor for raster output. Default value is 2.0.
285
+ w : float, default=None
286
+ Width of the output image in units.
287
+ Only applicable when exporting to PNG or PDF.
288
+ h : float, default=None
289
+ Height of the output image in units.
290
+ Only applicable when exporting to PNG or PDF.
291
+ unit : {'in', 'cm', 'mm', 'px'}, default='in'
292
+ Unit of the output image. One of: 'in', 'cm', 'mm' or 'px'.
293
+ Only applicable when exporting to PNG or PDF.
294
+ dpi : int, default=300
295
+ Resolution in dots per inch.
296
+ Only applicable when exporting to PNG or PDF.
297
+ The default value depends on the unit:
298
+
299
+ - for 'px' it is 96 (output image will have the same pixel size as ``w`` and ``h`` values)
300
+ - for physical units ('in', 'cm', 'mm') it is 300
301
+
302
+
303
+ Returns
304
+ -------
305
+ str
306
+ Absolute pathname of created file or None if a file-like object is provided.
307
+
308
+ Notes
309
+ -----
310
+ Export to a PDF file uses the pillow library.
311
+
312
+ Examples
313
+ --------
314
+ .. jupyter-execute::
315
+ :linenos:
316
+ :emphasize-lines: 12
317
+
318
+ import numpy as np
319
+ import io
320
+ import os
321
+ from lets_plot import *
322
+ LetsPlot.setup_html()
323
+ n = 60
324
+ np.random.seed(42)
325
+ x = np.random.choice(list('abcde'), size=n)
326
+ y = np.random.normal(size=n)
327
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
328
+ file_like = io.BytesIO()
329
+ p.to_pdf(file_like)
330
+ """
331
+ return _export_as_raster(self, path, scale, 'pdf', w=w, h=h, unit=unit, dpi=dpi)
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2025. JetBrains s.r.o.
2
+ # Use of this source code is governed by the MIT license that can be found in the LICENSE file.
3
+
4
+ from lets_plot.plot.core import PlotSpec
5
+ from ._global_theme import _get_global_theme
6
+ from .subplots import SupPlotsSpec
7
+
8
+
9
+ def _strip_theme_if_global(fig):
10
+ # Strip this global theme if defined
11
+ global_theme_options = _get_global_theme()
12
+
13
+ # Strip global theme options from plots in grid (see issue: #966).
14
+ if global_theme_options is not None and fig is not None and 'theme' in fig.props() and fig.props()[
15
+ 'theme'] == global_theme_options.props():
16
+ if isinstance(fig, PlotSpec):
17
+ fig = PlotSpec.duplicate(fig)
18
+ fig.props().pop('theme')
19
+ return fig
20
+ elif isinstance(fig, SupPlotsSpec):
21
+ fig = SupPlotsSpec.duplicate(fig)
22
+ fig.props().pop('theme')
23
+ return fig
24
+ return fig