lets-plot 4.7.0rc1__cp313-cp313-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.

Potentially problematic release.


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

Files changed (95) hide show
  1. lets_plot/__init__.py +283 -0
  2. lets_plot/_global_settings.py +196 -0
  3. lets_plot/_kbridge.py +141 -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 +100 -0
  8. lets_plot/bistro/corr.py +447 -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 +333 -0
  14. lets_plot/export/__init__.py +6 -0
  15. lets_plot/export/ggsave_.py +141 -0
  16. lets_plot/frontend_context/__init__.py +8 -0
  17. lets_plot/frontend_context/_configuration.py +151 -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 +19 -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 +3 -0
  48. lets_plot/plot/__init__.py +64 -0
  49. lets_plot/plot/_global_theme.py +14 -0
  50. lets_plot/plot/annotation.py +290 -0
  51. lets_plot/plot/coord.py +242 -0
  52. lets_plot/plot/core.py +1060 -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 +8839 -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 +392 -0
  60. lets_plot/plot/geom_livemap_.py +310 -0
  61. lets_plot/plot/ggbunch_.py +96 -0
  62. lets_plot/plot/gggrid_.py +126 -0
  63. lets_plot/plot/ggtb_.py +55 -0
  64. lets_plot/plot/guide.py +229 -0
  65. lets_plot/plot/label.py +187 -0
  66. lets_plot/plot/marginal_layer.py +181 -0
  67. lets_plot/plot/plot.py +244 -0
  68. lets_plot/plot/pos.py +320 -0
  69. lets_plot/plot/sampling.py +338 -0
  70. lets_plot/plot/sandbox_.py +26 -0
  71. lets_plot/plot/scale.py +3577 -0
  72. lets_plot/plot/scale_colormap_mpl.py +297 -0
  73. lets_plot/plot/scale_convenience.py +155 -0
  74. lets_plot/plot/scale_identity_.py +658 -0
  75. lets_plot/plot/scale_position.py +1342 -0
  76. lets_plot/plot/series_meta.py +203 -0
  77. lets_plot/plot/stat.py +581 -0
  78. lets_plot/plot/subplots.py +322 -0
  79. lets_plot/plot/subplots_util.py +24 -0
  80. lets_plot/plot/theme_.py +772 -0
  81. lets_plot/plot/theme_set.py +393 -0
  82. lets_plot/plot/tooltip.py +486 -0
  83. lets_plot/plot/util.py +237 -0
  84. lets_plot/settings_utils.py +244 -0
  85. lets_plot/tilesets.py +429 -0
  86. lets_plot-4.7.0rc1.dist-info/METADATA +196 -0
  87. lets_plot-4.7.0rc1.dist-info/RECORD +95 -0
  88. lets_plot-4.7.0rc1.dist-info/WHEEL +6 -0
  89. lets_plot-4.7.0rc1.dist-info/licenses/LICENSE +21 -0
  90. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.FreeType +166 -0
  91. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.ImageMagick +106 -0
  92. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.expat +21 -0
  93. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.fontconfig +200 -0
  94. lets_plot-4.7.0rc1.dist-info/top_level.txt +2 -0
  95. lets_plot_kotlin_bridge.cpython-313-x86_64-linux-gnu.so +0 -0
@@ -0,0 +1,322 @@
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()`
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) -> 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
+ Returns
132
+ -------
133
+ str
134
+ The result depends on the `path` parameter.
135
+ It can be the absolute path of the file,
136
+ SVG content as a string, or None if a file-like object is provided.
137
+
138
+ Examples
139
+ --------
140
+ .. jupyter-execute::
141
+ :linenos:
142
+ :emphasize-lines: 13
143
+
144
+ import numpy as np
145
+ import io
146
+ import os
147
+ from lets_plot import *
148
+ from IPython import display
149
+ LetsPlot.setup_html()
150
+ n = 60
151
+ np.random.seed(42)
152
+ x = np.random.choice(list('abcde'), size=n)
153
+ y = np.random.normal(size=n)
154
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
155
+ file_like = io.BytesIO()
156
+ p.to_svg(file_like)
157
+ display.SVG(file_like.getvalue())
158
+ """
159
+ return _to_svg(self, path)
160
+
161
+ def to_html(self, path=None, iframe: bool = None) -> str:
162
+ """
163
+ Export the plot in HTML format.
164
+
165
+ Parameters
166
+ ----------
167
+ self : `SupPlotsSpec`
168
+ Subplots specification to export.
169
+ path : str, file-like object, default=None
170
+ It can be a file path, file-like object, or None.
171
+ If a string is provided, the result will be exported to the file at that path.
172
+ If a file-like object is provided, the result will be exported to that object.
173
+ If None is provided, the result will be returned as a string.
174
+ iframe : bool, default=False
175
+ Whether to wrap HTML page into a iFrame.
176
+
177
+ Returns
178
+ -------
179
+ str
180
+ The result depends on the `path` parameter.
181
+ It can be the absolute path of the file,
182
+ HTML content as a string, or None if a file-like object is provided.
183
+
184
+ Examples
185
+ --------
186
+ .. jupyter-execute::
187
+ :linenos:
188
+ :emphasize-lines: 12
189
+
190
+ import numpy as np
191
+ import io
192
+ import os
193
+ from lets_plot import *
194
+ LetsPlot.setup_html()
195
+ n = 60
196
+ np.random.seed(42)
197
+ x = np.random.choice(list('abcde'), size=n)
198
+ y = np.random.normal(size=n)
199
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
200
+ file_like = io.BytesIO()
201
+ p.to_html(file_like)
202
+ """
203
+ return _to_html(self, path, iframe)
204
+
205
+ def to_png(self, path, scale=None, w=None, h=None, unit=None, dpi=None) -> str:
206
+ """
207
+ Export all plots currently in this 'bunch' to a file or file-like object in PNG format.
208
+
209
+ Parameters
210
+ ----------
211
+ self : `SupPlotsSpec`
212
+ Subplots specification to export.
213
+ path : str, file-like object
214
+ Сan be either a string specifying a file path or a file-like object.
215
+ If a string is provided, the result will be exported to the file at that path.
216
+ If a file-like object is provided, the result will be exported to that object.
217
+ scale : float
218
+ Scaling factor for raster output. Default value is 2.0.
219
+ w : float, default=None
220
+ Only applicable when exporting to PNG or PDF.
221
+ h : float, default=None
222
+ Height of the output image in units.
223
+ Only applicable when exporting to PNG or PDF.
224
+ unit : {'in', 'cm', 'mm'}, default='in'
225
+ Unit of the output image. One of: 'in', 'cm', 'mm'.
226
+ Only applicable when exporting to PNG or PDF.
227
+ dpi : int, default=300
228
+ Resolution in dots per inch.
229
+ Only applicable when exporting to PNG or PDF.
230
+
231
+ Returns
232
+ -------
233
+ str
234
+ Absolute pathname of created file or None if a file-like object is provided.
235
+
236
+ Notes
237
+ -----
238
+ Export to PNG file uses the CairoSVG library.
239
+ CairoSVG is free and distributed under the LGPL-3.0 license.
240
+ For more details visit: https://cairosvg.org/documentation/
241
+
242
+ Examples
243
+ --------
244
+ .. jupyter-execute::
245
+ :linenos:
246
+ :emphasize-lines: 13
247
+
248
+ import numpy as np
249
+ import io
250
+ import os
251
+ from lets_plot import *
252
+ from IPython import display
253
+ LetsPlot.setup_html()
254
+ n = 60
255
+ np.random.seed(42)
256
+ x = np.random.choice(list('abcde'), size=n)
257
+ y = np.random.normal(size=n)
258
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
259
+ file_like = io.BytesIO()
260
+ p.to_png(file_like)
261
+ display.Image(file_like.getvalue())
262
+ """
263
+ return _export_as_raster(self, path, scale, 'png', w=w, h=h, unit=unit, dpi=dpi)
264
+
265
+ def to_pdf(self, path, scale=None, w=None, h=None, unit=None, dpi=None) -> str:
266
+ """
267
+ Export all plots currently in this 'bunch' to a file or file-like object in PDF format.
268
+
269
+ Parameters
270
+ ----------
271
+ self : `SupPlotsSpec`
272
+ Subplots specification to export.
273
+ path : str, file-like object
274
+ Сan be either a string specifying a file path or a file-like object.
275
+ If a string is provided, the result will be exported to the file at that path.
276
+ If a file-like object is provided, the result will be exported to that object.
277
+ scale : float
278
+ Scaling factor for raster output. Default value is 2.0.
279
+ w : float, default=None
280
+ Width of the output image in units.
281
+ Only applicable when exporting to PNG or PDF.
282
+ h : float, default=None
283
+ Height of the output image in units.
284
+ Only applicable when exporting to PNG or PDF.
285
+ unit : {'in', 'cm', 'mm'}, default='in'
286
+ Unit of the output image. One of: 'in', 'cm', 'mm'.
287
+ Only applicable when exporting to PNG or PDF.
288
+ dpi : int, default=300
289
+ Resolution in dots per inch.
290
+ Only applicable when exporting to PNG or PDF.
291
+
292
+ Returns
293
+ -------
294
+ str
295
+ Absolute pathname of created file or None if a file-like object is provided.
296
+
297
+ Notes
298
+ -----
299
+ Export to PDF file uses the CairoSVG library.
300
+ CairoSVG is free and distributed under the LGPL-3.0 license.
301
+ For more details visit: https://cairosvg.org/documentation/
302
+
303
+ Examples
304
+ --------
305
+ .. jupyter-execute::
306
+ :linenos:
307
+ :emphasize-lines: 12
308
+
309
+ import numpy as np
310
+ import io
311
+ import os
312
+ from lets_plot import *
313
+ LetsPlot.setup_html()
314
+ n = 60
315
+ np.random.seed(42)
316
+ x = np.random.choice(list('abcde'), size=n)
317
+ y = np.random.normal(size=n)
318
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + geom_jitter()
319
+ file_like = io.BytesIO()
320
+ p.to_pdf(file_like)
321
+ """
322
+ 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