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,653 @@
|
|
|
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 .scale import _scale
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Identity Scales
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
__all__ = ['scale_identity',
|
|
12
|
+
'scale_color_identity',
|
|
13
|
+
'scale_fill_identity',
|
|
14
|
+
'scale_shape_identity',
|
|
15
|
+
'scale_linetype_identity',
|
|
16
|
+
'scale_alpha_identity',
|
|
17
|
+
'scale_size_identity',
|
|
18
|
+
'scale_linewidth_identity',
|
|
19
|
+
'scale_stroke_identity'
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def scale_identity(aesthetic, *,
|
|
24
|
+
name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
25
|
+
format=None, **other):
|
|
26
|
+
"""
|
|
27
|
+
Identity scale that maps already-scaled data directly to aesthetic values, without transformation.
|
|
28
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
aesthetic : str or list
|
|
33
|
+
The name(s) of the aesthetic(s) that this scale works with.
|
|
34
|
+
name : str
|
|
35
|
+
The name of the scale - used as the axis label or the legend title.
|
|
36
|
+
breaks : list or dict
|
|
37
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
38
|
+
labels : list of str or dict
|
|
39
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
40
|
+
lablim : int, default=None
|
|
41
|
+
The maximum label length (in characters) before trimming is applied.
|
|
42
|
+
limits : list
|
|
43
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
44
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
45
|
+
and the default order of their display in guides.
|
|
46
|
+
na_value
|
|
47
|
+
Missing values will be replaced with this value.
|
|
48
|
+
guide, default='none'
|
|
49
|
+
Guide to use for this scale.
|
|
50
|
+
format : str
|
|
51
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
52
|
+
|
|
53
|
+
- '.2f' -> '12.45'
|
|
54
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
55
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
56
|
+
|
|
57
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
58
|
+
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
``FeatureSpec`` or ``FeatureSpecArray``
|
|
62
|
+
Scales specification.
|
|
63
|
+
|
|
64
|
+
Examples
|
|
65
|
+
--------
|
|
66
|
+
.. jupyter-execute::
|
|
67
|
+
:linenos:
|
|
68
|
+
:emphasize-lines: 10
|
|
69
|
+
|
|
70
|
+
import numpy as np
|
|
71
|
+
from lets_plot import *
|
|
72
|
+
LetsPlot.setup_html()
|
|
73
|
+
n = 50
|
|
74
|
+
np.random.seed(42)
|
|
75
|
+
c = np.random.choice(['#e41a1c', '#377eb8', '#4daf4a'], size=n)
|
|
76
|
+
v = np.random.normal(size=n)
|
|
77
|
+
ggplot({'c': c, 'v': v}, aes(x='c', y='v')) + \\
|
|
78
|
+
geom_boxplot(aes(color='c', fill='c'), size=2) + \\
|
|
79
|
+
scale_identity(aesthetic=['color', 'fill'])
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
return _scale(aesthetic,
|
|
83
|
+
name=name,
|
|
84
|
+
breaks=breaks,
|
|
85
|
+
labels=labels,
|
|
86
|
+
lablim=lablim,
|
|
87
|
+
limits=limits,
|
|
88
|
+
expand=None,
|
|
89
|
+
na_value=na_value,
|
|
90
|
+
guide=guide,
|
|
91
|
+
trans=None,
|
|
92
|
+
format=format,
|
|
93
|
+
#
|
|
94
|
+
scale_mapper_kind='identity',
|
|
95
|
+
**other)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def scale_color_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
99
|
+
format=None):
|
|
100
|
+
"""
|
|
101
|
+
Identity color scale that maps already-scaled data directly to the color aesthetic without transformation.
|
|
102
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
name : str
|
|
107
|
+
The name of the scale - used as the axis label or the legend title.
|
|
108
|
+
breaks : list or dict
|
|
109
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
110
|
+
labels : list of str or dict
|
|
111
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
112
|
+
lablim : int, default=None
|
|
113
|
+
The maximum label length (in characters) before trimming is applied.
|
|
114
|
+
limits : list
|
|
115
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
116
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
117
|
+
and the default order of their display in guides.
|
|
118
|
+
guide, default='none'
|
|
119
|
+
Guide to use for this scale.
|
|
120
|
+
format : str
|
|
121
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
122
|
+
|
|
123
|
+
- '.2f' -> '12.45'
|
|
124
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
125
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
126
|
+
|
|
127
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
128
|
+
|
|
129
|
+
Returns
|
|
130
|
+
-------
|
|
131
|
+
``FeatureSpec``
|
|
132
|
+
Scale specification.
|
|
133
|
+
|
|
134
|
+
Notes
|
|
135
|
+
-----
|
|
136
|
+
For more info about input data format, see `Color and Fill <https://lets-plot.org/python/pages/aesthetics.html#color-and-fill>`__.
|
|
137
|
+
|
|
138
|
+
Examples
|
|
139
|
+
--------
|
|
140
|
+
.. jupyter-execute::
|
|
141
|
+
:linenos:
|
|
142
|
+
:emphasize-lines: 10
|
|
143
|
+
|
|
144
|
+
import numpy as np
|
|
145
|
+
from lets_plot import *
|
|
146
|
+
LetsPlot.setup_html()
|
|
147
|
+
n = 50
|
|
148
|
+
np.random.seed(42)
|
|
149
|
+
c = np.random.choice(['#e41a1c', '#377eb8', '#4daf4a'], size=n)
|
|
150
|
+
v = np.random.normal(size=n)
|
|
151
|
+
ggplot({'c': c, 'v': v}, aes(x='c', y='v')) + \\
|
|
152
|
+
geom_boxplot(aes(color='c'), size=2) + \\
|
|
153
|
+
scale_color_identity()
|
|
154
|
+
|
|
155
|
+
"""
|
|
156
|
+
return scale_identity('color',
|
|
157
|
+
name=name,
|
|
158
|
+
breaks=breaks,
|
|
159
|
+
labels=labels,
|
|
160
|
+
lablim=lablim,
|
|
161
|
+
limits=limits,
|
|
162
|
+
na_value=na_value,
|
|
163
|
+
guide=guide,
|
|
164
|
+
format=format)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def scale_fill_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
168
|
+
format=None):
|
|
169
|
+
"""
|
|
170
|
+
Identity fill scale that maps already-scaled data directly to the fill aesthetic without transformation.
|
|
171
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
172
|
+
|
|
173
|
+
Parameters
|
|
174
|
+
----------
|
|
175
|
+
name : str
|
|
176
|
+
The name of the scale - used as the axis label or the legend title.
|
|
177
|
+
breaks : list or dict
|
|
178
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
179
|
+
labels : list of str or dict
|
|
180
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
181
|
+
lablim : int, default=None
|
|
182
|
+
The maximum label length (in characters) before trimming is applied.
|
|
183
|
+
limits : list
|
|
184
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
185
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
186
|
+
and the default order of their display in guides.
|
|
187
|
+
guide, default='none'
|
|
188
|
+
Guide to use for this scale.
|
|
189
|
+
format : str
|
|
190
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
191
|
+
|
|
192
|
+
- '.2f' -> '12.45'
|
|
193
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
194
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
195
|
+
|
|
196
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
197
|
+
|
|
198
|
+
Returns
|
|
199
|
+
-------
|
|
200
|
+
``FeatureSpec``
|
|
201
|
+
Scale specification.
|
|
202
|
+
|
|
203
|
+
Notes
|
|
204
|
+
-----
|
|
205
|
+
For more info about input data format, see `Color and Fill <https://lets-plot.org/python/pages/aesthetics.html#color-and-fill>`__.
|
|
206
|
+
|
|
207
|
+
Examples
|
|
208
|
+
--------
|
|
209
|
+
.. jupyter-execute::
|
|
210
|
+
:linenos:
|
|
211
|
+
:emphasize-lines: 8-10
|
|
212
|
+
|
|
213
|
+
import numpy as np
|
|
214
|
+
from lets_plot import *
|
|
215
|
+
LetsPlot.setup_html()
|
|
216
|
+
np.random.seed(42)
|
|
217
|
+
colors = {'red': '#e41a1c', 'green': '#4daf4a', 'blue': '#377eb8'}
|
|
218
|
+
c = np.random.choice(list(colors.values()), size=20)
|
|
219
|
+
ggplot({'c': c}, aes(x='c')) + geom_bar(aes(fill='c')) + \\
|
|
220
|
+
scale_fill_identity(guide=guide_legend(), name='color', \\
|
|
221
|
+
breaks=list(colors.values()), \\
|
|
222
|
+
labels=list(colors.keys()))
|
|
223
|
+
|
|
224
|
+
"""
|
|
225
|
+
return scale_identity('fill',
|
|
226
|
+
name=name,
|
|
227
|
+
breaks=breaks,
|
|
228
|
+
labels=labels,
|
|
229
|
+
lablim=lablim,
|
|
230
|
+
limits=limits,
|
|
231
|
+
na_value=na_value,
|
|
232
|
+
guide=guide,
|
|
233
|
+
format=format)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def scale_shape_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
237
|
+
format=None):
|
|
238
|
+
"""
|
|
239
|
+
Identity shape scale that maps already-scaled data directly to the shape aesthetic without transformation.
|
|
240
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
241
|
+
|
|
242
|
+
Parameters
|
|
243
|
+
----------
|
|
244
|
+
name : str
|
|
245
|
+
The name of the scale - used as the axis label or the legend title.
|
|
246
|
+
breaks : list or dict
|
|
247
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
248
|
+
labels : list of str or dict
|
|
249
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
250
|
+
lablim : int, default=None
|
|
251
|
+
The maximum label length (in characters) before trimming is applied.
|
|
252
|
+
limits : list
|
|
253
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
254
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
255
|
+
and the default order of their display in guides.
|
|
256
|
+
guide, default='none'
|
|
257
|
+
Guide to use for this scale.
|
|
258
|
+
format : str
|
|
259
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
260
|
+
|
|
261
|
+
- '.2f' -> '12.45'
|
|
262
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
263
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
264
|
+
|
|
265
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
266
|
+
|
|
267
|
+
Returns
|
|
268
|
+
-------
|
|
269
|
+
``FeatureSpec``
|
|
270
|
+
Scale specification.
|
|
271
|
+
|
|
272
|
+
Notes
|
|
273
|
+
-----
|
|
274
|
+
Input data expected: numeric codes of shapes.
|
|
275
|
+
|
|
276
|
+
Examples
|
|
277
|
+
--------
|
|
278
|
+
.. jupyter-execute::
|
|
279
|
+
:linenos:
|
|
280
|
+
:emphasize-lines: 11
|
|
281
|
+
|
|
282
|
+
from lets_plot import *
|
|
283
|
+
LetsPlot.setup_html()
|
|
284
|
+
n, m = 26, 6
|
|
285
|
+
x = [i % m for i in range(n)]
|
|
286
|
+
y = [int(i / m) for i in range(n)]
|
|
287
|
+
s = list(range(n))
|
|
288
|
+
ggplot({'x': x, 'y': y, 's': s}, aes('x', 'y')) + \\
|
|
289
|
+
geom_point(aes(shape='s'), size=10, show_legend=False, \\
|
|
290
|
+
color='#2166ac', fill='#fddbc7', \\
|
|
291
|
+
tooltips=layer_tooltips().line('shape #@s')) + \\
|
|
292
|
+
scale_shape_identity()
|
|
293
|
+
|
|
294
|
+
"""
|
|
295
|
+
return scale_identity('shape',
|
|
296
|
+
name=name,
|
|
297
|
+
breaks=breaks,
|
|
298
|
+
labels=labels,
|
|
299
|
+
lablim=lablim,
|
|
300
|
+
limits=limits,
|
|
301
|
+
na_value=na_value,
|
|
302
|
+
guide=guide,
|
|
303
|
+
format=format)
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
def scale_linetype_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
307
|
+
format=None):
|
|
308
|
+
"""
|
|
309
|
+
Identity linetype scale that maps already-scaled data directly to the linetype aesthetic without transformation.
|
|
310
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
311
|
+
|
|
312
|
+
Parameters
|
|
313
|
+
----------
|
|
314
|
+
name : str
|
|
315
|
+
The name of the scale - used as the axis label or the legend title.
|
|
316
|
+
breaks : list or dict
|
|
317
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
318
|
+
labels : list of str or dict
|
|
319
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
320
|
+
lablim : int, default=None
|
|
321
|
+
The maximum label length (in characters) before trimming is applied.
|
|
322
|
+
limits : list
|
|
323
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
324
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
325
|
+
and the default order of their display in guides.
|
|
326
|
+
guide, default='none'
|
|
327
|
+
Guide to use for this scale.
|
|
328
|
+
format : str
|
|
329
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
330
|
+
|
|
331
|
+
- '.2f' -> '12.45'
|
|
332
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
333
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
334
|
+
|
|
335
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
336
|
+
|
|
337
|
+
Returns
|
|
338
|
+
-------
|
|
339
|
+
``FeatureSpec``
|
|
340
|
+
Scale specification.
|
|
341
|
+
|
|
342
|
+
Notes
|
|
343
|
+
-----
|
|
344
|
+
Input data expected: numeric codes or names of line types (e.g. 'dotdash').
|
|
345
|
+
The codes are: 0 = 'blank', 1 = 'solid', 2 = 'dashed', 3 = 'dotted', 4 = 'dotdash',
|
|
346
|
+
5 = 'longdash', 6 = 'twodash'.
|
|
347
|
+
|
|
348
|
+
Examples
|
|
349
|
+
--------
|
|
350
|
+
.. jupyter-execute::
|
|
351
|
+
:linenos:
|
|
352
|
+
:emphasize-lines: 13
|
|
353
|
+
|
|
354
|
+
from lets_plot import *
|
|
355
|
+
LetsPlot.setup_html()
|
|
356
|
+
n = 7
|
|
357
|
+
data = {
|
|
358
|
+
'x': [0] * n,
|
|
359
|
+
'xend': [1] * n,
|
|
360
|
+
'y': list(range(n)),
|
|
361
|
+
'yend': list(range(n)),
|
|
362
|
+
}
|
|
363
|
+
ggplot(data) + \\
|
|
364
|
+
geom_segment(aes(x='x', xend='xend', y='y', \\
|
|
365
|
+
yend='yend', linetype='y')) + \\
|
|
366
|
+
scale_linetype_identity()
|
|
367
|
+
|
|
368
|
+
"""
|
|
369
|
+
return scale_identity('linetype',
|
|
370
|
+
name=name,
|
|
371
|
+
breaks=breaks,
|
|
372
|
+
labels=labels,
|
|
373
|
+
lablim=lablim,
|
|
374
|
+
limits=limits,
|
|
375
|
+
na_value=na_value,
|
|
376
|
+
guide=guide,
|
|
377
|
+
format=format)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def scale_alpha_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
381
|
+
format=None):
|
|
382
|
+
"""
|
|
383
|
+
Identity alpha scale that maps already-scaled data directly to the alpha aesthetic without transformation.
|
|
384
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
385
|
+
|
|
386
|
+
Parameters
|
|
387
|
+
----------
|
|
388
|
+
name : str
|
|
389
|
+
The name of the scale - used as the axis label or the legend title.
|
|
390
|
+
breaks : list or dict
|
|
391
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
392
|
+
labels : list of str or dict
|
|
393
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
394
|
+
lablim : int, default=None
|
|
395
|
+
The maximum label length (in characters) before trimming is applied.
|
|
396
|
+
limits : list
|
|
397
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
398
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
399
|
+
and the default order of their display in guides.
|
|
400
|
+
guide, default='none'
|
|
401
|
+
Guide to use for this scale.
|
|
402
|
+
format : str
|
|
403
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
404
|
+
|
|
405
|
+
- '.2f' -> '12.45'
|
|
406
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
407
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
408
|
+
|
|
409
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
410
|
+
|
|
411
|
+
Returns
|
|
412
|
+
-------
|
|
413
|
+
``FeatureSpec``
|
|
414
|
+
Scale specification.
|
|
415
|
+
|
|
416
|
+
Notes
|
|
417
|
+
-----
|
|
418
|
+
Input data expected: numeric values in range [0, 1].
|
|
419
|
+
|
|
420
|
+
Examples
|
|
421
|
+
--------
|
|
422
|
+
.. jupyter-execute::
|
|
423
|
+
:linenos:
|
|
424
|
+
:emphasize-lines: 11
|
|
425
|
+
|
|
426
|
+
import numpy as np
|
|
427
|
+
from lets_plot import *
|
|
428
|
+
LetsPlot.setup_html()
|
|
429
|
+
n = 100
|
|
430
|
+
np.random.seed(42)
|
|
431
|
+
x = np.random.normal(size=n)
|
|
432
|
+
y = np.random.normal(size=n)
|
|
433
|
+
a = np.random.uniform(0, .5, size=n)
|
|
434
|
+
ggplot({'x': x, 'y': y, 'a': a}, aes('x', 'y')) + \\
|
|
435
|
+
geom_point(aes(alpha='a'), shape=21, size=10) + \\
|
|
436
|
+
scale_alpha_identity(limits=[.2, .5], breaks=[.2, .3, .4, .5])
|
|
437
|
+
|
|
438
|
+
"""
|
|
439
|
+
return scale_identity('alpha',
|
|
440
|
+
name=name,
|
|
441
|
+
breaks=breaks,
|
|
442
|
+
labels=labels,
|
|
443
|
+
lablim=lablim,
|
|
444
|
+
limits=limits,
|
|
445
|
+
na_value=na_value,
|
|
446
|
+
guide=guide,
|
|
447
|
+
format=format)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def scale_size_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
451
|
+
format=None):
|
|
452
|
+
"""
|
|
453
|
+
Identity size scale that maps already-scaled data directly to the size aesthetic without transformation.
|
|
454
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
455
|
+
|
|
456
|
+
Parameters
|
|
457
|
+
----------
|
|
458
|
+
name : str
|
|
459
|
+
The name of the scale - used as the axis label or the legend title.
|
|
460
|
+
breaks : list or dict
|
|
461
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
462
|
+
labels : list of str or dict
|
|
463
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
464
|
+
lablim : int, default=None
|
|
465
|
+
The maximum label length (in characters) before trimming is applied.
|
|
466
|
+
limits : list
|
|
467
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
468
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
469
|
+
and the default order of their display in guides.
|
|
470
|
+
guide, default='none'
|
|
471
|
+
Guide to use for this scale.
|
|
472
|
+
format : str
|
|
473
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
474
|
+
|
|
475
|
+
- '.2f' -> '12.45'
|
|
476
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
477
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
478
|
+
|
|
479
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
480
|
+
|
|
481
|
+
Returns
|
|
482
|
+
-------
|
|
483
|
+
``FeatureSpec``
|
|
484
|
+
Scale specification.
|
|
485
|
+
|
|
486
|
+
Notes
|
|
487
|
+
-----
|
|
488
|
+
Input data expected: positive numeric values.
|
|
489
|
+
|
|
490
|
+
Examples
|
|
491
|
+
--------
|
|
492
|
+
.. jupyter-execute::
|
|
493
|
+
:linenos:
|
|
494
|
+
:emphasize-lines: 11
|
|
495
|
+
|
|
496
|
+
import numpy as np
|
|
497
|
+
from lets_plot import *
|
|
498
|
+
LetsPlot.setup_html()
|
|
499
|
+
n = 100
|
|
500
|
+
np.random.seed(42)
|
|
501
|
+
x = np.random.normal(size=n)
|
|
502
|
+
y = np.random.normal(size=n)
|
|
503
|
+
w = np.random.choice([8, 10, 12], size=n)
|
|
504
|
+
ggplot({'x': x, 'y': y, 'w': w}, aes('x', 'y')) + \\
|
|
505
|
+
geom_point(aes(size='w'), shape=21, alpha=.2) + \\
|
|
506
|
+
scale_size_identity()
|
|
507
|
+
|
|
508
|
+
"""
|
|
509
|
+
return scale_identity('size',
|
|
510
|
+
name=name,
|
|
511
|
+
breaks=breaks,
|
|
512
|
+
labels=labels,
|
|
513
|
+
lablim=lablim,
|
|
514
|
+
limits=limits,
|
|
515
|
+
na_value=na_value,
|
|
516
|
+
guide=guide,
|
|
517
|
+
format=format)
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def scale_linewidth_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
521
|
+
format=None):
|
|
522
|
+
"""
|
|
523
|
+
Identity linewidth scale that maps already-scaled data directly to the linewidth aesthetic without transformation.
|
|
524
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
525
|
+
|
|
526
|
+
Parameters
|
|
527
|
+
----------
|
|
528
|
+
name : str
|
|
529
|
+
The name of the scale - used as the axis label or the legend title.
|
|
530
|
+
breaks : list or dict
|
|
531
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
532
|
+
labels : list of str or dict
|
|
533
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
534
|
+
lablim : int, default=None
|
|
535
|
+
The maximum label length (in characters) before trimming is applied.
|
|
536
|
+
limits : list
|
|
537
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
538
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
539
|
+
and the default order of their display in guides.
|
|
540
|
+
guide, default='none'
|
|
541
|
+
Guide to use for this scale.
|
|
542
|
+
format : str
|
|
543
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
544
|
+
|
|
545
|
+
- '.2f' -> '12.45'
|
|
546
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
547
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
548
|
+
|
|
549
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
550
|
+
|
|
551
|
+
Returns
|
|
552
|
+
-------
|
|
553
|
+
``FeatureSpec``
|
|
554
|
+
Scale specification.
|
|
555
|
+
|
|
556
|
+
Notes
|
|
557
|
+
-----
|
|
558
|
+
Input data expected: positive numeric values.
|
|
559
|
+
|
|
560
|
+
Examples
|
|
561
|
+
--------
|
|
562
|
+
.. jupyter-execute::
|
|
563
|
+
:linenos:
|
|
564
|
+
:emphasize-lines: 9
|
|
565
|
+
|
|
566
|
+
from lets_plot import *
|
|
567
|
+
LetsPlot.setup_html()
|
|
568
|
+
data = {
|
|
569
|
+
'x': [0, 1, 2],
|
|
570
|
+
'y': [1, 2, 1],
|
|
571
|
+
'w': [1, 3, 2],
|
|
572
|
+
}
|
|
573
|
+
ggplot(data, aes('x', 'y')) + geom_lollipop(aes(linewidth='w')) + \\
|
|
574
|
+
scale_linewidth_identity()
|
|
575
|
+
|
|
576
|
+
"""
|
|
577
|
+
return scale_identity('linewidth',
|
|
578
|
+
name=name,
|
|
579
|
+
breaks=breaks,
|
|
580
|
+
labels=labels,
|
|
581
|
+
lablim=lablim,
|
|
582
|
+
limits=limits,
|
|
583
|
+
na_value=na_value,
|
|
584
|
+
guide=guide,
|
|
585
|
+
format=format)
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def scale_stroke_identity(name=None, breaks=None, labels=None, lablim=None, limits=None, na_value=None, guide='none',
|
|
589
|
+
format=None):
|
|
590
|
+
"""
|
|
591
|
+
Identity stroke scale that maps already-scaled data directly to the stroke aesthetic without transformation.
|
|
592
|
+
This scale does not produce a legend unless breaks and labels are supplied.
|
|
593
|
+
|
|
594
|
+
Parameters
|
|
595
|
+
----------
|
|
596
|
+
name : str
|
|
597
|
+
The name of the scale - used as the axis label or the legend title.
|
|
598
|
+
breaks : list or dict
|
|
599
|
+
A list of data values specifying the positions of ticks, or a dictionary which maps the tick labels to the breaks values.
|
|
600
|
+
labels : list of str or dict
|
|
601
|
+
A list of labels on ticks, or a dictionary which maps the breaks values to the tick labels.
|
|
602
|
+
lablim : int, default=None
|
|
603
|
+
The maximum label length (in characters) before trimming is applied.
|
|
604
|
+
limits : list
|
|
605
|
+
Continuous scale: a numeric vector of length two providing limits of the scale.
|
|
606
|
+
Discrete scale: a vector specifying the data range for the scale
|
|
607
|
+
and the default order of their display in guides.
|
|
608
|
+
guide, default='none'
|
|
609
|
+
Guide to use for this scale.
|
|
610
|
+
format : str
|
|
611
|
+
Define the format for labels on the scale. The syntax resembles Python's:
|
|
612
|
+
|
|
613
|
+
- '.2f' -> '12.45'
|
|
614
|
+
- 'Num {}' -> 'Num 12.456789'
|
|
615
|
+
- 'TTL: {.2f}$' -> 'TTL: 12.45$'
|
|
616
|
+
|
|
617
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
618
|
+
|
|
619
|
+
Returns
|
|
620
|
+
-------
|
|
621
|
+
``FeatureSpec``
|
|
622
|
+
Scale specification.
|
|
623
|
+
|
|
624
|
+
Notes
|
|
625
|
+
-----
|
|
626
|
+
Input data expected: positive numeric values.
|
|
627
|
+
|
|
628
|
+
Examples
|
|
629
|
+
--------
|
|
630
|
+
.. jupyter-execute::
|
|
631
|
+
:linenos:
|
|
632
|
+
:emphasize-lines: 9
|
|
633
|
+
|
|
634
|
+
from lets_plot import *
|
|
635
|
+
LetsPlot.setup_html()
|
|
636
|
+
data = {
|
|
637
|
+
'x': [0, 1, 2],
|
|
638
|
+
'y': [1, 2, 1],
|
|
639
|
+
's': [1, 3, 2],
|
|
640
|
+
}
|
|
641
|
+
ggplot(data, aes('x', 'y')) + geom_lollipop(aes(stroke='s')) + \\
|
|
642
|
+
scale_stroke_identity()
|
|
643
|
+
|
|
644
|
+
"""
|
|
645
|
+
return scale_identity('stroke',
|
|
646
|
+
name=name,
|
|
647
|
+
breaks=breaks,
|
|
648
|
+
labels=labels,
|
|
649
|
+
lablim=lablim,
|
|
650
|
+
limits=limits,
|
|
651
|
+
na_value=na_value,
|
|
652
|
+
guide=guide,
|
|
653
|
+
format=format)
|