lets-plot 4.4.1__cp311-cp311-win_amd64.whl → 4.5.0rc1__cp311-cp311-win_amd64.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.

@@ -5,6 +5,7 @@
5
5
  from .annotation import *
6
6
  from .coord import *
7
7
  from .core import *
8
+ from .expand_limits_ import *
8
9
  from .facet import *
9
10
  from .font_features import *
10
11
  from .geom import *
@@ -56,5 +57,6 @@ __all__ = (coord.__all__ +
56
57
  marginal_layer.__all__ +
57
58
  font_features.__all__ +
58
59
  gggrid_.__all__ +
59
- ggtb_.__all__
60
+ ggtb_.__all__ +
61
+ expand_limits_.__all__
60
62
  )
lets_plot/plot/core.py CHANGED
@@ -12,7 +12,7 @@ __all__ = ['aes', 'layer']
12
12
  from lets_plot._global_settings import get_global_bool, has_global_value, FRAGMENTS_ENABLED
13
13
 
14
14
 
15
- def aes(x=None, y=None, **other):
15
+ def aes(x=None, y=None, **kwargs):
16
16
  """
17
17
  Define aesthetic mappings.
18
18
 
@@ -69,7 +69,7 @@ def aes(x=None, y=None, **other):
69
69
 
70
70
  """
71
71
 
72
- return FeatureSpec('mapping', name=None, x=x, y=y, **other)
72
+ return FeatureSpec('mapping', name=None, x=x, y=y, **kwargs)
73
73
 
74
74
 
75
75
  def layer(geom=None, stat=None, data=None, mapping=None, position=None, **kwargs):
@@ -397,8 +397,14 @@ class PlotSpec(FeatureSpec):
397
397
  return plot
398
398
 
399
399
  if other.kind == 'guides':
400
- existing_guides_options = plot.props().get('guides', {})
401
- plot.props()['guides'] = _merge_dicts_recursively(existing_guides_options, other.as_dict())
400
+ existing_options = plot.props().get('guides', {})
401
+ plot.props()['guides'] = _merge_dicts_recursively(existing_options, other.as_dict())
402
+ return plot
403
+
404
+ if other.kind == 'mapping': # +aes(..)
405
+ existing_spec = plot.props().get('mapping', aes())
406
+ merged_mapping = {**existing_spec.as_dict(), **other.as_dict()}
407
+ plot.props()['mapping'] = aes(**merged_mapping)
402
408
  return plot
403
409
 
404
410
  # add feature to properties
@@ -901,7 +907,7 @@ def _export_as_raster(spec, path, scale: float, export_format: str, w=None, h=No
901
907
 
902
908
  if any(it is not None for it in [w, h, unit, dpi]):
903
909
  if w is None or h is None or unit is None or dpi is None:
904
- raise ValueError("w, h, unit and dpi must be specified")
910
+ raise ValueError("w, h, unit, and dpi must all be specified")
905
911
 
906
912
  w, h = _to_inches(w, unit) * dpi, _to_inches(h, unit) * dpi
907
913
  export_function(bytestring=svg, write_to=path, dpi=dpi, output_width=w, output_height=h)
@@ -0,0 +1,78 @@
1
+ # Copyright (c) 2024. 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
+ from .core import aes
4
+ from .geom import geom_blank
5
+
6
+ __all__ = ['expand_limits']
7
+
8
+ def expand_limits(*, x=None, y=None, size=None, color=None, fill=None, alpha=None, shape=None):
9
+ """
10
+ Expand the plot limits to include additional data values.
11
+
12
+ This function extends the plot boundaries to encompass new data points,
13
+ whether a single value or multiple values are provided. It acts as a
14
+ thin wrapper around geom_blank().
15
+
16
+ Parameters
17
+ ----------
18
+ x, y, size, color, fill, alpha, shape : Any, list, tuple or range
19
+ List of name-value pairs specifying the value (or values) that should be included in each scale.
20
+ These parameters extend the corresponding plot dimensions or aesthetic scales.
21
+
22
+ Returns
23
+ -------
24
+ FeatureSpec
25
+ A result of the `geom_blank()` call.
26
+
27
+ Examples
28
+ --------
29
+ .. jupyter-execute::
30
+ :linenos:
31
+ :emphasize-lines: 10
32
+
33
+ from lets_plot import *
34
+ LetsPlot.setup_html()
35
+ data = {
36
+ 'x': [-3, 0, 1],
37
+ 'y': [2, 3, -1],
38
+ }
39
+
40
+ # Include the value -10 along the x-axis
41
+ ggplot(data, aes('x', 'y')) + geom_point() + \
42
+ expand_limits(x=-10)
43
+
44
+ |
45
+
46
+ .. jupyter-execute::
47
+ :linenos:
48
+ :emphasize-lines: 10
49
+
50
+ from lets_plot import *
51
+ LetsPlot.setup_html()
52
+ data = {
53
+ 'x': [-3, 0, 1],
54
+ 'y': [2, 3, -1],
55
+ }
56
+
57
+ # Expand Limits Along the y-axis
58
+ ggplot(data, aes('x', 'y')) + geom_point() + \
59
+ expand_limits(y=range(-10, 10))
60
+
61
+ """
62
+ params = locals()
63
+
64
+ def standardize(value):
65
+ if isinstance(value, (list, tuple, range)):
66
+ return list(value)
67
+ else:
68
+ return [value]
69
+
70
+ standardized = {k: standardize(v) for k, v in params.items()}
71
+
72
+ # Drop all undefined but keep x and y even if undefined.
73
+ cleaned = {k: v for k, v in standardized.items() if k in ['x', 'y'] or not all(e is None for e in v)}
74
+
75
+ max_length = max(len(v) for v in cleaned.values())
76
+ data = {k: v + [None] * (max_length - len(v)) for k, v in cleaned.items()}
77
+
78
+ return geom_blank(mapping=aes(**data))
lets_plot/plot/facet.py CHANGED
@@ -38,10 +38,12 @@ def facet_grid(x=None, y=None, *, scales=None, x_order=1, y_order=1,
38
38
  Specify the format pattern for displaying faceting values in rows.
39
39
  x_labwidth : int, default=None
40
40
  The maximum label length (in characters) before a line breaking is applied.
41
- If the original facet label already contains `\\\\n` as a text separator, the line breaking is not applied.
41
+ If the original facet label already contains `\\\\n` as a text separator, it splits at those points first,
42
+ then wraps each part according to `x_labwidth`.
42
43
  y_labwidth : int, default=None
43
44
  The maximum label length (in characters) before a line breaking is applied.
44
- If the original facet label already contains `\\\\n` as a text separator, the line breaking is not applied.
45
+ If the original facet label already contains `\\\\n` as a text separator, it splits at those points first,
46
+ then wraps each part according to `y_labwidth`.
45
47
 
46
48
  Returns
47
49
  -------
@@ -133,7 +135,9 @@ def facet_wrap(facets, ncol=None, nrow=None, *, scales=None, order=1, format=Non
133
135
  Direction: either 'h' for horizontal, or 'v' for vertical.
134
136
  labwidth : int or list
135
137
  The maximum label length (in characters) before a line breaking is applied.
136
- If the original facet label already contains `\\\\n` as a text separator, the line breaking is not applied.
138
+ If the original facet label already contains `\\\\n` as a text separator, it splits at those points first,
139
+ then wraps each part according to `labwidth`.
140
+
137
141
 
138
142
  Returns
139
143
  -------