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,486 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2020. 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 typing import List
|
|
6
|
+
|
|
7
|
+
from lets_plot.plot.core import FeatureSpec, _filter_none
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# Tooltips
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
__all__ = ['layer_tooltips']
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class layer_tooltips(FeatureSpec):
|
|
17
|
+
"""
|
|
18
|
+
Configure tooltips.
|
|
19
|
+
|
|
20
|
+
Notes
|
|
21
|
+
-----
|
|
22
|
+
Set tooltips='none' to hide tooltips from this layer.
|
|
23
|
+
|
|
24
|
+
Examples
|
|
25
|
+
--------
|
|
26
|
+
.. jupyter-execute::
|
|
27
|
+
:linenos:
|
|
28
|
+
:emphasize-lines: 15
|
|
29
|
+
|
|
30
|
+
import numpy as np
|
|
31
|
+
from lets_plot import *
|
|
32
|
+
LetsPlot.setup_html()
|
|
33
|
+
n = 100
|
|
34
|
+
np.random.seed(42)
|
|
35
|
+
data = {
|
|
36
|
+
'id': np.arange(n),
|
|
37
|
+
'x': np.random.normal(size=n),
|
|
38
|
+
'y': np.random.normal(size=n),
|
|
39
|
+
'c': np.random.choice(['a', 'b'], size=n),
|
|
40
|
+
'w': np.random.randint(1, 11, size=n)
|
|
41
|
+
}
|
|
42
|
+
ggplot(data, aes('x', 'y')) + \\
|
|
43
|
+
geom_point(aes(color='c', size='w'), \\
|
|
44
|
+
tooltips=layer_tooltips().line('@c "@id"')
|
|
45
|
+
.line('---')
|
|
46
|
+
.format('@y', '.2f')
|
|
47
|
+
.line('(x, y)|(^x, @y)')
|
|
48
|
+
.line('@|@w')) + \\
|
|
49
|
+
scale_size(range=[2, 4])
|
|
50
|
+
|
|
51
|
+
|
|
|
52
|
+
|
|
53
|
+
.. jupyter-execute::
|
|
54
|
+
:linenos:
|
|
55
|
+
:emphasize-lines: 12
|
|
56
|
+
|
|
57
|
+
import numpy as np
|
|
58
|
+
from lets_plot import *
|
|
59
|
+
LetsPlot.setup_html()
|
|
60
|
+
n = 100
|
|
61
|
+
np.random.seed(42)
|
|
62
|
+
data = {
|
|
63
|
+
'x': np.random.normal(size=n),
|
|
64
|
+
'y': np.random.normal(size=n),
|
|
65
|
+
'c': np.random.randint(10, size=n)
|
|
66
|
+
}
|
|
67
|
+
ggplot(data, aes('x', 'y')) + \\
|
|
68
|
+
geom_point(aes(color='c'), tooltips='none')
|
|
69
|
+
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
def __init__(self, variables: List[str] = None):
|
|
73
|
+
"""
|
|
74
|
+
Initialize self.
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
variables : list of str
|
|
79
|
+
Variable names to place in the general tooltip with default formatting.
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
self._tooltip_formats: List = []
|
|
84
|
+
self._tooltip_lines: List = None
|
|
85
|
+
self._tooltip_anchor = None
|
|
86
|
+
self._tooltip_min_width = None
|
|
87
|
+
self._tooltip_color = None
|
|
88
|
+
self._tooltip_variables = variables
|
|
89
|
+
self._tooltip_title = None
|
|
90
|
+
self._disable_splitting = None
|
|
91
|
+
super().__init__('tooltips', name=None)
|
|
92
|
+
|
|
93
|
+
def as_dict(self):
|
|
94
|
+
"""
|
|
95
|
+
Return the dictionary of all properties of the object.
|
|
96
|
+
|
|
97
|
+
Returns
|
|
98
|
+
-------
|
|
99
|
+
dict
|
|
100
|
+
Dictionary of properties.
|
|
101
|
+
|
|
102
|
+
Examples
|
|
103
|
+
--------
|
|
104
|
+
.. jupyter-execute::
|
|
105
|
+
:linenos:
|
|
106
|
+
:emphasize-lines: 6
|
|
107
|
+
|
|
108
|
+
from lets_plot import *
|
|
109
|
+
LetsPlot.setup_html()
|
|
110
|
+
layer_tooltips().format('@x', '.2f')\\
|
|
111
|
+
.line('@x @y')\\
|
|
112
|
+
.line('^fill')\\
|
|
113
|
+
.as_dict()
|
|
114
|
+
|
|
115
|
+
"""
|
|
116
|
+
d = super().as_dict()
|
|
117
|
+
d['formats'] = self._tooltip_formats
|
|
118
|
+
d['lines'] = self._tooltip_lines
|
|
119
|
+
d['tooltip_anchor'] = self._tooltip_anchor
|
|
120
|
+
d['tooltip_min_width'] = self._tooltip_min_width
|
|
121
|
+
d['tooltip_color'] = self._tooltip_color
|
|
122
|
+
d['variables'] = self._tooltip_variables
|
|
123
|
+
d['title'] = self._tooltip_title
|
|
124
|
+
d['disable_splitting'] = self._disable_splitting
|
|
125
|
+
return _filter_none(d)
|
|
126
|
+
|
|
127
|
+
def format(self, field=None, format=None):
|
|
128
|
+
"""
|
|
129
|
+
Define the format for displaying the value.
|
|
130
|
+
This format will be applied to the mapped value in the default tooltip
|
|
131
|
+
or to the corresponding value specified in the 'line' template.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
field : str
|
|
136
|
+
Name of an aesthetic or variable that would be formatted.
|
|
137
|
+
The field name starts with a '^' prefix for aesthetics,
|
|
138
|
+
the variable name starts with a '@' prefix or without any prefix.
|
|
139
|
+
format : str
|
|
140
|
+
Formatting specification. The format contains a number format ('1.f'),
|
|
141
|
+
a string template ('{.1f}') or a date/time format ('%d.%m.%y').
|
|
142
|
+
The numeric format for non-numeric value will be ignored.
|
|
143
|
+
If you need to include a brace character in the literal text,
|
|
144
|
+
it can be escaped by doubling: ``{{`` and ``}}``.
|
|
145
|
+
|
|
146
|
+
Returns
|
|
147
|
+
-------
|
|
148
|
+
``layer_tooltips``
|
|
149
|
+
Layer tooltips specification.
|
|
150
|
+
|
|
151
|
+
Notes
|
|
152
|
+
-----
|
|
153
|
+
It's possible to set the format for all positional aesthetics:
|
|
154
|
+
|
|
155
|
+
- field='^X' - for all positional x,
|
|
156
|
+
- field='^Y' - for all positional y.
|
|
157
|
+
|
|
158
|
+
----
|
|
159
|
+
|
|
160
|
+
The string template in ``format`` will allow to change lines
|
|
161
|
+
for the default tooltip without ``line`` specifying.
|
|
162
|
+
Also the template will change the line for side tooltips.
|
|
163
|
+
Aes and var formats are not interchangeable, i.e. var format
|
|
164
|
+
will not be applied to aes, mapped to this variable.
|
|
165
|
+
|
|
166
|
+
----
|
|
167
|
+
|
|
168
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
169
|
+
|
|
170
|
+
Examples
|
|
171
|
+
--------
|
|
172
|
+
.. jupyter-execute::
|
|
173
|
+
:linenos:
|
|
174
|
+
:emphasize-lines: 15-16, 18, 20, 22
|
|
175
|
+
|
|
176
|
+
import numpy as np
|
|
177
|
+
from lets_plot import *
|
|
178
|
+
LetsPlot.setup_html()
|
|
179
|
+
n = 100
|
|
180
|
+
np.random.seed(42)
|
|
181
|
+
data = {
|
|
182
|
+
'a': np.random.normal(size=n),
|
|
183
|
+
'b': np.random.normal(size=n),
|
|
184
|
+
'c': np.random.choice(['X', 'Y'], size=n),
|
|
185
|
+
'd': np.random.uniform(size=n),
|
|
186
|
+
'e': np.random.randint(100, size=n)
|
|
187
|
+
}
|
|
188
|
+
ggplot(data, aes('a', 'b')) + \\
|
|
189
|
+
geom_point(aes(shape='c', size='e', color='d'), show_legend=False, \\
|
|
190
|
+
tooltips=layer_tooltips().format(field='a', format='.1f')\\
|
|
191
|
+
.format('^y', '.1f')\\
|
|
192
|
+
.line('(@a, ^y)')\\
|
|
193
|
+
.format('c', '{{{}}}')\\
|
|
194
|
+
.line('@|@c')\\
|
|
195
|
+
.format('^color', '≈ {.2f}')\\
|
|
196
|
+
.line('@|^color')\\
|
|
197
|
+
.format('e', '{}%')\\
|
|
198
|
+
.line('e|@e')) + \\
|
|
199
|
+
scale_size(range=[2, 4])
|
|
200
|
+
|
|
201
|
+
|
|
|
202
|
+
|
|
203
|
+
.. jupyter-execute::
|
|
204
|
+
:linenos:
|
|
205
|
+
:emphasize-lines: 11-13
|
|
206
|
+
|
|
207
|
+
import numpy as np
|
|
208
|
+
from lets_plot import *
|
|
209
|
+
LetsPlot.setup_html()
|
|
210
|
+
n = 50
|
|
211
|
+
np.random.seed(42)
|
|
212
|
+
data = {
|
|
213
|
+
'v': np.random.normal(size=n),
|
|
214
|
+
'c': np.random.choice(['a', 'b', 'c'], size=n),
|
|
215
|
+
}
|
|
216
|
+
ggplot(data, aes('c', 'v')) + \\
|
|
217
|
+
geom_boxplot(tooltips=layer_tooltips().format('^Y', '.4f')\\
|
|
218
|
+
.format('^ymin', 'min y: {.2f}')\\
|
|
219
|
+
.format('^ymax', 'max y: {.2f}'))
|
|
220
|
+
|
|
221
|
+
"""
|
|
222
|
+
self._tooltip_formats.append({"field": field, "format": format})
|
|
223
|
+
return self
|
|
224
|
+
|
|
225
|
+
def line(self, value):
|
|
226
|
+
"""
|
|
227
|
+
Line to show in the tooltip.
|
|
228
|
+
Add a line template to the tooltip with a label.
|
|
229
|
+
|
|
230
|
+
Parameters
|
|
231
|
+
----------
|
|
232
|
+
value : str
|
|
233
|
+
Enriched string which becomes one line of the tooltip.
|
|
234
|
+
|
|
235
|
+
Returns
|
|
236
|
+
-------
|
|
237
|
+
``layer_tooltips``
|
|
238
|
+
Layer tooltips specification.
|
|
239
|
+
|
|
240
|
+
Notes
|
|
241
|
+
-----
|
|
242
|
+
Variables and aesthetics can be accessed via special syntax:
|
|
243
|
+
|
|
244
|
+
- ^color for aes,
|
|
245
|
+
- @x for variable,
|
|
246
|
+
- @{x + 1} for variable with spaces in the name,
|
|
247
|
+
- @{x^2 + 1} for variable with spaces and '^' symbol in the name,
|
|
248
|
+
- @x^2 for variable with '^' symbol in its name.
|
|
249
|
+
|
|
250
|
+
A '^' symbol can be escaped with a backslash, a brace character
|
|
251
|
+
in the literal text - by doubling:
|
|
252
|
+
|
|
253
|
+
- 'x\\\\^2' -> "x^2"
|
|
254
|
+
- '{{x}}' -> "{x}"
|
|
255
|
+
|
|
256
|
+
The specified 'line' for side tooltip will move it to the general multi-line tooltip.
|
|
257
|
+
The default tooltip has a label before the value,
|
|
258
|
+
usually containing the name of the mapped variable.
|
|
259
|
+
It has its own behaviour, like blank label for axis aesthetics.
|
|
260
|
+
This default label can be set in template using a pair of symbols '@|'.
|
|
261
|
+
The label can be overridden by specifying a string value before '|' symbol.
|
|
262
|
+
Within the tooltip line the label is left-aligned,
|
|
263
|
+
the string formed by template is right-aligned.
|
|
264
|
+
If a label is not specified, the string will be centered in the tooltip.
|
|
265
|
+
|
|
266
|
+
Examples
|
|
267
|
+
--------
|
|
268
|
+
.. jupyter-execute::
|
|
269
|
+
:linenos:
|
|
270
|
+
:emphasize-lines: 12, 14
|
|
271
|
+
|
|
272
|
+
import numpy as np
|
|
273
|
+
from lets_plot import *
|
|
274
|
+
LetsPlot.setup_html()
|
|
275
|
+
n = 100
|
|
276
|
+
np.random.seed(42)
|
|
277
|
+
x = np.linspace(-3, 3, n)
|
|
278
|
+
y = 9 - x ** 2 + np.random.normal(scale=.3, size=n)
|
|
279
|
+
data = {'x': x, '9 - x^2': y}
|
|
280
|
+
ggplot(data) + \\
|
|
281
|
+
geom_point(aes('x', '9 - x^2'), \\
|
|
282
|
+
tooltips=layer_tooltips().format('x', '.3f')\\
|
|
283
|
+
.line('x = @x')\\
|
|
284
|
+
.format('9 - x^2', '.3f')\\
|
|
285
|
+
.line('9 - x\\^2 = @{9 - x^2}'))
|
|
286
|
+
|
|
287
|
+
|
|
|
288
|
+
|
|
289
|
+
.. jupyter-execute::
|
|
290
|
+
:linenos:
|
|
291
|
+
:emphasize-lines: 17-20
|
|
292
|
+
|
|
293
|
+
import numpy as np
|
|
294
|
+
from lets_plot import *
|
|
295
|
+
LetsPlot.setup_html()
|
|
296
|
+
n = 100
|
|
297
|
+
np.random.seed(42)
|
|
298
|
+
data = {
|
|
299
|
+
'x': np.random.normal(size=n),
|
|
300
|
+
'y': np.random.normal(size=n),
|
|
301
|
+
'c': np.random.choice(['X', 'Y'], size=n),
|
|
302
|
+
'p': np.random.uniform(size=n),
|
|
303
|
+
'w': np.random.randint(100, size=n)
|
|
304
|
+
}
|
|
305
|
+
ggplot(data, aes('x', 'y')) + \\
|
|
306
|
+
geom_point(aes(shape='c', size='w', color='p'), show_legend=False, \\
|
|
307
|
+
tooltips=layer_tooltips().format('x', '.2f')\\
|
|
308
|
+
.format('y', '.2f')\\
|
|
309
|
+
.line('(^x, ^y)')\\
|
|
310
|
+
.line('|^shape')\\
|
|
311
|
+
.line('@|^color')\\
|
|
312
|
+
.line('w|^size')) + \\
|
|
313
|
+
scale_size(range=[2, 4])
|
|
314
|
+
|
|
315
|
+
"""
|
|
316
|
+
if self._tooltip_lines is None:
|
|
317
|
+
self._tooltip_lines = []
|
|
318
|
+
self._tooltip_lines.append(value)
|
|
319
|
+
return self
|
|
320
|
+
|
|
321
|
+
def anchor(self, value):
|
|
322
|
+
"""
|
|
323
|
+
Specify a fixed position for a general tooltip.
|
|
324
|
+
|
|
325
|
+
Parameters
|
|
326
|
+
----------
|
|
327
|
+
value : {'top_left', 'top_center', 'top_right', 'middle_left', 'middle_center', 'middle_right', 'bottom_left', 'bottom_center', 'bottom_right'}
|
|
328
|
+
Type of the tooltip anchoring.
|
|
329
|
+
|
|
330
|
+
Returns
|
|
331
|
+
-------
|
|
332
|
+
``layer_tooltips``
|
|
333
|
+
Layer tooltips specification.
|
|
334
|
+
|
|
335
|
+
Examples
|
|
336
|
+
--------
|
|
337
|
+
.. jupyter-execute::
|
|
338
|
+
:linenos:
|
|
339
|
+
:emphasize-lines: 10
|
|
340
|
+
|
|
341
|
+
import numpy as np
|
|
342
|
+
from lets_plot import *
|
|
343
|
+
LetsPlot.setup_html()
|
|
344
|
+
n = 100
|
|
345
|
+
np.random.seed(42)
|
|
346
|
+
x = np.random.normal(size=n)
|
|
347
|
+
y = np.random.normal(size=n)
|
|
348
|
+
ggplot({'x': x, 'y': y}, aes('x', 'y')) + \\
|
|
349
|
+
geom_point(tooltips=layer_tooltips().line('(^x, ^y)')\\
|
|
350
|
+
.anchor('top_center'))
|
|
351
|
+
|
|
352
|
+
"""
|
|
353
|
+
self._tooltip_anchor = value
|
|
354
|
+
return self
|
|
355
|
+
|
|
356
|
+
def min_width(self, value):
|
|
357
|
+
"""
|
|
358
|
+
Minimum width of the general tooltip.
|
|
359
|
+
|
|
360
|
+
Parameters
|
|
361
|
+
----------
|
|
362
|
+
value : float
|
|
363
|
+
Minimum width value in px.
|
|
364
|
+
|
|
365
|
+
Returns
|
|
366
|
+
-------
|
|
367
|
+
``layer_tooltips``
|
|
368
|
+
Layer tooltips specification.
|
|
369
|
+
|
|
370
|
+
Examples
|
|
371
|
+
--------
|
|
372
|
+
.. jupyter-execute::
|
|
373
|
+
:linenos:
|
|
374
|
+
:emphasize-lines: 10
|
|
375
|
+
|
|
376
|
+
import numpy as np
|
|
377
|
+
from lets_plot import *
|
|
378
|
+
LetsPlot.setup_html()
|
|
379
|
+
n = 100
|
|
380
|
+
np.random.seed(42)
|
|
381
|
+
x = np.random.normal(size=n)
|
|
382
|
+
y = np.random.normal(size=n)
|
|
383
|
+
ggplot({'x': x, 'y': y}, aes('x', 'y')) + \\
|
|
384
|
+
geom_point(tooltips=layer_tooltips().line('(^x, ^y)')\\
|
|
385
|
+
.min_width(200))
|
|
386
|
+
|
|
387
|
+
"""
|
|
388
|
+
self._tooltip_min_width = value
|
|
389
|
+
return self
|
|
390
|
+
|
|
391
|
+
def color(self, value):
|
|
392
|
+
"""
|
|
393
|
+
Function ``color(value)`` is deprecated.
|
|
394
|
+
|
|
395
|
+
"""
|
|
396
|
+
print("WARN: The function color() is deprecated and is no longer supported.")
|
|
397
|
+
|
|
398
|
+
self._tooltip_color = value
|
|
399
|
+
return self
|
|
400
|
+
|
|
401
|
+
def title(self, value):
|
|
402
|
+
"""
|
|
403
|
+
Line with title to show in the tooltip.
|
|
404
|
+
Add a title template to the tooltip.
|
|
405
|
+
|
|
406
|
+
Parameters
|
|
407
|
+
----------
|
|
408
|
+
value : str
|
|
409
|
+
Enriched string which becomes the title of the tooltip.
|
|
410
|
+
|
|
411
|
+
Returns
|
|
412
|
+
-------
|
|
413
|
+
``layer_tooltips``
|
|
414
|
+
Layer tooltips specification.
|
|
415
|
+
|
|
416
|
+
Notes
|
|
417
|
+
-----
|
|
418
|
+
The specification rules are the same as for the ``lines()`` function:
|
|
419
|
+
variables and aesthetics can be used in the template.
|
|
420
|
+
The resulting string will be at the beginning of the general tooltip, centered and highlighted in bold.
|
|
421
|
+
A long title can be split into multiple lines using ``\\n`` as a text separator.
|
|
422
|
+
|
|
423
|
+
Examples
|
|
424
|
+
--------
|
|
425
|
+
.. jupyter-execute::
|
|
426
|
+
:linenos:
|
|
427
|
+
:emphasize-lines: 15
|
|
428
|
+
|
|
429
|
+
import numpy as np
|
|
430
|
+
from lets_plot import *
|
|
431
|
+
LetsPlot.setup_html()
|
|
432
|
+
n = 100
|
|
433
|
+
np.random.seed(42)
|
|
434
|
+
data = {
|
|
435
|
+
'id': np.arange(n),
|
|
436
|
+
'x': np.random.normal(size=n),
|
|
437
|
+
'y': np.random.normal(size=n),
|
|
438
|
+
'c': np.random.choice(['a', 'b'], size=n),
|
|
439
|
+
'w': np.random.randint(1, 11, size=n)
|
|
440
|
+
}
|
|
441
|
+
ggplot(data, aes('x', 'y')) + \\
|
|
442
|
+
geom_point(aes(color='c', size='w'), show_legend=False, \\
|
|
443
|
+
tooltips=layer_tooltips().title('@id')
|
|
444
|
+
.line('color|@c')
|
|
445
|
+
.line('size|@w'))
|
|
446
|
+
|
|
447
|
+
"""
|
|
448
|
+
self._tooltip_title = value
|
|
449
|
+
return self
|
|
450
|
+
|
|
451
|
+
def disable_splitting(self):
|
|
452
|
+
"""
|
|
453
|
+
Hide side tooltips.
|
|
454
|
+
|
|
455
|
+
Returns
|
|
456
|
+
-------
|
|
457
|
+
``layer_tooltips``
|
|
458
|
+
Layer tooltips specification.
|
|
459
|
+
|
|
460
|
+
Notes
|
|
461
|
+
-----
|
|
462
|
+
By default, the ``disable_splitting()`` function moves all side tooltips to the general tooltip.
|
|
463
|
+
If the content of a general tooltip is specified with the ``line()`` functions,
|
|
464
|
+
the general tooltip will get the given lines, and the side tooltips will be hidden.
|
|
465
|
+
|
|
466
|
+
Examples
|
|
467
|
+
--------
|
|
468
|
+
.. jupyter-execute::
|
|
469
|
+
:linenos:
|
|
470
|
+
:emphasize-lines: 10
|
|
471
|
+
|
|
472
|
+
import numpy as np
|
|
473
|
+
from lets_plot import *
|
|
474
|
+
LetsPlot.setup_html()
|
|
475
|
+
n = 50
|
|
476
|
+
np.random.seed(42)
|
|
477
|
+
data = {
|
|
478
|
+
'v': np.random.normal(size=n),
|
|
479
|
+
'c': np.random.choice(['a', 'b', 'c'], size=n),
|
|
480
|
+
}
|
|
481
|
+
ggplot(data, aes('c', 'v')) + \\
|
|
482
|
+
geom_boxplot(tooltips=layer_tooltips().disable_splitting())
|
|
483
|
+
|
|
484
|
+
"""
|
|
485
|
+
self._disable_splitting = True
|
|
486
|
+
return self
|