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
|
@@ -0,0 +1,338 @@
|
|
|
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__ = ['sampling_random',
|
|
8
|
+
'sampling_random_stratified',
|
|
9
|
+
'sampling_pick',
|
|
10
|
+
'sampling_systematic',
|
|
11
|
+
'sampling_group_random',
|
|
12
|
+
'sampling_group_systematic',
|
|
13
|
+
'sampling_vertex_vw',
|
|
14
|
+
'sampling_vertex_dp']
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def sampling_random(n, seed=None):
|
|
18
|
+
"""
|
|
19
|
+
Return a subset of randomly selected items.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
n : int
|
|
24
|
+
Number of items to return.
|
|
25
|
+
seed : int
|
|
26
|
+
Number used to initialize a pseudo random number generator.
|
|
27
|
+
|
|
28
|
+
Returns
|
|
29
|
+
-------
|
|
30
|
+
``FeatureSpec``
|
|
31
|
+
Random sample specification.
|
|
32
|
+
|
|
33
|
+
Examples
|
|
34
|
+
--------
|
|
35
|
+
.. jupyter-execute::
|
|
36
|
+
:linenos:
|
|
37
|
+
:emphasize-lines: 10
|
|
38
|
+
|
|
39
|
+
import numpy as np
|
|
40
|
+
from lets_plot import *
|
|
41
|
+
LetsPlot.setup_html()
|
|
42
|
+
np.random.seed(27)
|
|
43
|
+
mean = np.zeros(2)
|
|
44
|
+
cov = [[.9, -.6],
|
|
45
|
+
[-.6, .9]]
|
|
46
|
+
x, y = np.random.multivariate_normal(mean, cov, 10000).T
|
|
47
|
+
ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
|
|
48
|
+
geom_point(sampling=sampling_random(1000, 35))
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
return _sampling('random', n=n, seed=seed)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def sampling_random_stratified(n, seed=None, min_subsample=None):
|
|
55
|
+
"""
|
|
56
|
+
Randomly sample from each stratum (subgroup).
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
n : int
|
|
61
|
+
Number of items to return.
|
|
62
|
+
seed : int
|
|
63
|
+
Number used to initialize a pseudo random number generator.
|
|
64
|
+
min_subsample : int
|
|
65
|
+
Minimal number of items in sub sample.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
``FeatureSpec``
|
|
70
|
+
Stratified random sample specification.
|
|
71
|
+
|
|
72
|
+
Examples
|
|
73
|
+
--------
|
|
74
|
+
.. jupyter-execute::
|
|
75
|
+
:linenos:
|
|
76
|
+
:emphasize-lines: 10
|
|
77
|
+
|
|
78
|
+
import numpy as np
|
|
79
|
+
from lets_plot import *
|
|
80
|
+
LetsPlot.setup_html()
|
|
81
|
+
np.random.seed(27)
|
|
82
|
+
n = 1000
|
|
83
|
+
x = np.random.normal(0, 1, n)
|
|
84
|
+
y = np.random.normal(0, 1, n)
|
|
85
|
+
cond = np.random.choice(['a', 'b'], n, p=[.9, .1])
|
|
86
|
+
ggplot({'x': x, 'y': y, 'cond': cond}, aes('x', 'y', color='cond')) + \\
|
|
87
|
+
geom_point(sampling=sampling_random_stratified(50, 35, min_subsample=10))
|
|
88
|
+
|
|
89
|
+
"""
|
|
90
|
+
return _sampling('random_stratified', n=n, seed=seed, min_subsample=min_subsample)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def sampling_pick(n):
|
|
94
|
+
"""
|
|
95
|
+
'Pick' sampling.
|
|
96
|
+
|
|
97
|
+
Parameters
|
|
98
|
+
----------
|
|
99
|
+
n : int
|
|
100
|
+
Number of items to return.
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
-------
|
|
104
|
+
``FeatureSpec``
|
|
105
|
+
Sample specification.
|
|
106
|
+
|
|
107
|
+
Examples
|
|
108
|
+
--------
|
|
109
|
+
.. jupyter-execute::
|
|
110
|
+
:linenos:
|
|
111
|
+
:emphasize-lines: 7
|
|
112
|
+
|
|
113
|
+
import numpy as np
|
|
114
|
+
from lets_plot import *
|
|
115
|
+
LetsPlot.setup_html()
|
|
116
|
+
x = np.linspace(-2, 2, 30)
|
|
117
|
+
y = x ** 2
|
|
118
|
+
ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
|
|
119
|
+
geom_line(sampling=sampling_pick(20))
|
|
120
|
+
|
|
121
|
+
"""
|
|
122
|
+
return _sampling('pick', n=n)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def sampling_systematic(n):
|
|
126
|
+
"""
|
|
127
|
+
Return a subset where items are selected at a regular interval.
|
|
128
|
+
|
|
129
|
+
Parameters
|
|
130
|
+
----------
|
|
131
|
+
n : int
|
|
132
|
+
Number of items to return.
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
-------
|
|
136
|
+
``FeatureSpec``
|
|
137
|
+
Systematic sample specification.
|
|
138
|
+
|
|
139
|
+
Examples
|
|
140
|
+
--------
|
|
141
|
+
.. jupyter-execute::
|
|
142
|
+
:linenos:
|
|
143
|
+
:emphasize-lines: 9
|
|
144
|
+
|
|
145
|
+
import numpy as np
|
|
146
|
+
from lets_plot import *
|
|
147
|
+
LetsPlot.setup_html()
|
|
148
|
+
n = 1000
|
|
149
|
+
x = np.arange(n)
|
|
150
|
+
np.random.seed(12)
|
|
151
|
+
y = np.random.normal(0, 1, n)
|
|
152
|
+
ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
|
|
153
|
+
geom_line(sampling=sampling_systematic(50))
|
|
154
|
+
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
return _sampling('systematic', n=n)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def sampling_group_systematic(n):
|
|
161
|
+
"""
|
|
162
|
+
Return a subset where groups are selected at a regular interval.
|
|
163
|
+
|
|
164
|
+
Parameters
|
|
165
|
+
----------
|
|
166
|
+
n : int
|
|
167
|
+
Number of groups to return.
|
|
168
|
+
|
|
169
|
+
Returns
|
|
170
|
+
-------
|
|
171
|
+
``FeatureSpec``
|
|
172
|
+
Group systematic sample specification.
|
|
173
|
+
|
|
174
|
+
Examples
|
|
175
|
+
--------
|
|
176
|
+
.. jupyter-execute::
|
|
177
|
+
:linenos:
|
|
178
|
+
:emphasize-lines: 11
|
|
179
|
+
|
|
180
|
+
import numpy as np
|
|
181
|
+
from lets_plot import *
|
|
182
|
+
LetsPlot.setup_html()
|
|
183
|
+
waves_count = 100
|
|
184
|
+
peak_amplitude = np.linspace(1, 2, waves_count)
|
|
185
|
+
wave_x = np.linspace(-np.pi, np.pi, 30)
|
|
186
|
+
x = np.tile(wave_x, waves_count)
|
|
187
|
+
y = np.array([a * np.sin(wave_x) for a in peak_amplitude]).flatten()
|
|
188
|
+
a = np.repeat(peak_amplitude, wave_x.size)
|
|
189
|
+
ggplot({'x': x, 'y': y, 'a': a}, aes('x', 'y')) + \\
|
|
190
|
+
geom_line(aes(group='a', color='a'), sampling=sampling_group_systematic(10))
|
|
191
|
+
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
return _sampling('group_systematic', n=n)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def sampling_group_random(n, seed=None):
|
|
198
|
+
"""
|
|
199
|
+
Return a subset of randomly selected groups.
|
|
200
|
+
|
|
201
|
+
Parameters
|
|
202
|
+
----------
|
|
203
|
+
n : int
|
|
204
|
+
Number of groups to return.
|
|
205
|
+
seed : int
|
|
206
|
+
Number used to initialize a pseudo random number generator.
|
|
207
|
+
|
|
208
|
+
Returns
|
|
209
|
+
-------
|
|
210
|
+
``FeatureSpec``
|
|
211
|
+
Group sample specification.
|
|
212
|
+
|
|
213
|
+
Examples
|
|
214
|
+
--------
|
|
215
|
+
.. jupyter-execute::
|
|
216
|
+
:linenos:
|
|
217
|
+
:emphasize-lines: 11
|
|
218
|
+
|
|
219
|
+
import numpy as np
|
|
220
|
+
from lets_plot import *
|
|
221
|
+
LetsPlot.setup_html()
|
|
222
|
+
waves_count = 100
|
|
223
|
+
peak_amplitude = np.linspace(1, 2, waves_count)
|
|
224
|
+
wave_x = np.linspace(-np.pi, np.pi, 30)
|
|
225
|
+
x = np.tile(wave_x, waves_count)
|
|
226
|
+
y = np.array([a * np.sin(wave_x) for a in peak_amplitude]).flatten()
|
|
227
|
+
a = np.repeat(peak_amplitude, wave_x.size)
|
|
228
|
+
ggplot({'x': x, 'y': y, 'a': a}, aes('x', 'y')) + \\
|
|
229
|
+
geom_line(aes(group='a', color='a'), sampling=sampling_group_random(10, 35))
|
|
230
|
+
|
|
231
|
+
"""
|
|
232
|
+
return _sampling('group_random', n=n, seed=seed)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def sampling_vertex_vw(n, polygon=None):
|
|
236
|
+
"""
|
|
237
|
+
Simplify a polyline using the Visvalingam-Whyatt algorithm.
|
|
238
|
+
|
|
239
|
+
Parameters
|
|
240
|
+
----------
|
|
241
|
+
n : int
|
|
242
|
+
Number of items to return.
|
|
243
|
+
|
|
244
|
+
polygon : bool, default=None
|
|
245
|
+
If True, the input data is considered as a polygon rings.
|
|
246
|
+
If False, the input data is considered as a polyline.
|
|
247
|
+
None for auto-detection.
|
|
248
|
+
|
|
249
|
+
Returns
|
|
250
|
+
-------
|
|
251
|
+
``FeatureSpec``
|
|
252
|
+
Vertices sample specification.
|
|
253
|
+
|
|
254
|
+
Notes
|
|
255
|
+
-----
|
|
256
|
+
Vertex sampling is designed for polygon simplification.
|
|
257
|
+
|
|
258
|
+
Examples
|
|
259
|
+
--------
|
|
260
|
+
.. jupyter-execute::
|
|
261
|
+
:linenos:
|
|
262
|
+
:emphasize-lines: 17
|
|
263
|
+
|
|
264
|
+
import numpy as np
|
|
265
|
+
from scipy.stats import multivariate_normal
|
|
266
|
+
from lets_plot import *
|
|
267
|
+
LetsPlot.setup_html()
|
|
268
|
+
np.random.seed(42)
|
|
269
|
+
n = 300
|
|
270
|
+
x = np.linspace(-1, 1, n)
|
|
271
|
+
y = np.linspace(-1, 1, n)
|
|
272
|
+
X, Y = np.meshgrid(x, y)
|
|
273
|
+
mean = np.zeros(2)
|
|
274
|
+
cov = [[1, .5],
|
|
275
|
+
[.5, 1]]
|
|
276
|
+
rv = multivariate_normal(mean, cov)
|
|
277
|
+
Z = rv.pdf(np.dstack((X, Y)))
|
|
278
|
+
data = {'x': X.flatten(), 'y': Y.flatten(), 'z': Z.flatten()}
|
|
279
|
+
ggplot(data, aes(x='x', y='y', z='z')) + \\
|
|
280
|
+
geom_contour(sampling=sampling_vertex_vw(150))
|
|
281
|
+
|
|
282
|
+
"""
|
|
283
|
+
return _sampling('vertex_vw', n=n, polygon=polygon)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def sampling_vertex_dp(n, polygon=None):
|
|
287
|
+
"""
|
|
288
|
+
Simplify a polyline using the Douglas-Peucker algorithm.
|
|
289
|
+
|
|
290
|
+
Parameters
|
|
291
|
+
----------
|
|
292
|
+
n : int
|
|
293
|
+
Number of items to return.
|
|
294
|
+
|
|
295
|
+
polygon : bool, default=None
|
|
296
|
+
If True, the input data is considered as a polygon rings.
|
|
297
|
+
If False, the input data is considered as a polyline.
|
|
298
|
+
None for auto-detection.
|
|
299
|
+
|
|
300
|
+
Returns
|
|
301
|
+
-------
|
|
302
|
+
``FeatureSpec``
|
|
303
|
+
Vertices sample specification.
|
|
304
|
+
|
|
305
|
+
Notes
|
|
306
|
+
-----
|
|
307
|
+
Vertex sampling is designed for polygon simplification.
|
|
308
|
+
|
|
309
|
+
Examples
|
|
310
|
+
--------
|
|
311
|
+
.. jupyter-execute::
|
|
312
|
+
:linenos:
|
|
313
|
+
:emphasize-lines: 17
|
|
314
|
+
|
|
315
|
+
import numpy as np
|
|
316
|
+
from scipy.stats import multivariate_normal
|
|
317
|
+
from lets_plot import *
|
|
318
|
+
LetsPlot.setup_html()
|
|
319
|
+
np.random.seed(42)
|
|
320
|
+
n = 300
|
|
321
|
+
x = np.linspace(-1, 1, n)
|
|
322
|
+
y = np.linspace(-1, 1, n)
|
|
323
|
+
X, Y = np.meshgrid(x, y)
|
|
324
|
+
mean = np.zeros(2)
|
|
325
|
+
cov = [[1, .5],
|
|
326
|
+
[.5, 1]]
|
|
327
|
+
rv = multivariate_normal(mean, cov)
|
|
328
|
+
Z = rv.pdf(np.dstack((X, Y)))
|
|
329
|
+
data = {'x': X.flatten(), 'y': Y.flatten(), 'z': Z.flatten()}
|
|
330
|
+
ggplot(data, aes(x='x', y='y', z='z')) + \\
|
|
331
|
+
geom_contour(sampling=sampling_vertex_dp(100))
|
|
332
|
+
|
|
333
|
+
"""
|
|
334
|
+
return _sampling('vertex_dp', n=n, polygon=polygon)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def _sampling(name, **kwargs):
|
|
338
|
+
return FeatureSpec('sampling', name, **kwargs)
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
# import numpy as np
|
|
6
|
+
#
|
|
7
|
+
# from lets_plot.geom_imshow_ import geom_imshow
|
|
8
|
+
#
|
|
9
|
+
# print("1")
|
|
10
|
+
# img = np.array([
|
|
11
|
+
# [[0, 0, 0, 128], [255, 255, 255, 128]]
|
|
12
|
+
# ])
|
|
13
|
+
#
|
|
14
|
+
# print(img)
|
|
15
|
+
# # print(geom_imshow(image_data=img))
|
|
16
|
+
# geom_imshow(image_data=img)
|
|
17
|
+
#
|
|
18
|
+
# print("2")
|
|
19
|
+
# img = np.array([
|
|
20
|
+
# [[0., 0., 0., .5], [1., 1., 1., .5]]
|
|
21
|
+
# ])
|
|
22
|
+
#
|
|
23
|
+
# print(img)
|
|
24
|
+
# geom_imshow(image_data=img)
|
|
25
|
+
#
|
|
26
|
+
# print(geom_imshow(image_data=img))
|