lets-plot 4.6.0a2__cp312-cp312-macosx_11_0_arm64.whl → 4.6.1__cp312-cp312-macosx_11_0_arm64.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.

lets_plot/plot/geom.py CHANGED
@@ -939,8 +939,8 @@ def geom_histogram(mapping=None, *, data=None, stat=None, position=None, show_le
939
939
  Result of the call to the `sampling_xxx()` function.
940
940
  To prevent any sampling for this layer pass value "none" (string "none").
941
941
  threshold : float, default=None
942
- If a bin's `..count..` is less than the threshold, the bin will be removed.
943
- Dropping empty bins is particularly useful for faceted plots with free scales.
942
+ If a bin's `..count..` is less than the threshold, it will be removed, but only if it is on the left or right edge of the histogram.
943
+ Dropping empty edge bins is particularly useful for faceted plots with free scales.
944
944
  tooltips : `layer_tooltips`
945
945
  Result of the call to the `layer_tooltips()` function.
946
946
  Specify appearance, style and content.
@@ -1253,10 +1253,6 @@ def geom_bin2d(mapping=None, *, data=None, stat=None, position=None, show_legend
1253
1253
  Apply a rectangular grid to the plane, count observations in each cell (bin) of the grid,
1254
1254
  and map the count to the fill color of the cell (tile).
1255
1255
 
1256
- By default, this geom uses `coord_fixed()`.
1257
- However, this may not be the best choice when the values on the X/Y axis have significantly different magnitudes.
1258
- In such cases, try using `coord_cartesian()`.
1259
-
1260
1256
  Parameters
1261
1257
  ----------
1262
1258
  mapping : `FeatureSpec`
@@ -1427,16 +1423,13 @@ def geom_hex(mapping=None, *, data=None, stat=None, position=None, show_legend=N
1427
1423
  bins=None,
1428
1424
  binwidth=None,
1429
1425
  drop=None,
1426
+ width_unit=None, height_unit=None,
1430
1427
  color_by=None, fill_by=None,
1431
1428
  **other_args):
1432
1429
  """
1433
1430
  Apply a hexagonal grid to the plane, count observations in each cell (hexagonal bin) of the grid,
1434
1431
  and map the count to the fill color of the cell (hexagonal tile).
1435
1432
 
1436
- By default, this geom uses `coord_fixed()`.
1437
- However, this may not be the best choice when the values on the X/Y axis have significantly different magnitudes.
1438
- In such cases, try using `coord_cartesian()`.
1439
-
1440
1433
  Parameters
1441
1434
  ----------
1442
1435
  mapping : `FeatureSpec`
@@ -1473,6 +1466,24 @@ def geom_hex(mapping=None, *, data=None, stat=None, position=None, show_legend=N
1473
1466
  Override `bins`. The default is to use bin widths that cover the entire range of the data.
1474
1467
  drop : bool, default=True
1475
1468
  Specify whether to remove all hexagonal bins with 0 counts.
1469
+ width_unit : {'res', 'identity', 'size', 'px'}, default='res'
1470
+ Unit for width of the hexagon.
1471
+ Possible values:
1472
+
1473
+ - 'res': if `stat='binhex'`, the unit equals the hexagonal bin width (`binwidth[0]`); otherwise, it represents the smallest distance between adjacent hexagons along the corresponding axis;
1474
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
1475
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
1476
+ - 'px': the unit is measured in screen pixels.
1477
+
1478
+ height_unit : {'res', 'identity', 'size', 'px'}, default='res'
1479
+ Unit for height of the hexagon.
1480
+ Possible values:
1481
+
1482
+ - 'res': if `stat='binhex'`, the unit equals the hexagonal bin height (`binwidth[1]`); otherwise, it represents the smallest distance between adjacent hexagons along the corresponding axis;
1483
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
1484
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
1485
+ - 'px': the unit is measured in screen pixels.
1486
+
1476
1487
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
1477
1488
  Define the color aesthetic for the geometry.
1478
1489
  fill_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='fill'
@@ -1570,6 +1581,21 @@ def geom_hex(mapping=None, *, data=None, stat=None, position=None, show_legend=N
1570
1581
  fill='darkgreen') + \\
1571
1582
  ggsize(600, 450)
1572
1583
 
1584
+ |
1585
+
1586
+ .. jupyter-execute::
1587
+ :linenos:
1588
+ :emphasize-lines: 7-8
1589
+
1590
+ import numpy as np
1591
+ from lets_plot import *
1592
+ LetsPlot.setup_html()
1593
+ np.random.seed(42)
1594
+ x, y = np.random.multivariate_normal(mean=[-98, 39], cov=[[100, 0], [0, 10]], size=100).T
1595
+ ggplot() + geom_livemap() + \\
1596
+ geom_hex(aes(x, y, fill='..density..'), \\
1597
+ bins=[10, 5], alpha=.5, show_legend=False)
1598
+
1573
1599
  """
1574
1600
  return _geom('hex',
1575
1601
  mapping=mapping,
@@ -1584,6 +1610,7 @@ def geom_hex(mapping=None, *, data=None, stat=None, position=None, show_legend=N
1584
1610
  bins=bins,
1585
1611
  binwidth=binwidth,
1586
1612
  drop=drop,
1613
+ width_unit=width_unit, height_unit=height_unit,
1587
1614
  color_by=color_by, fill_by=fill_by,
1588
1615
  **other_args)
1589
1616
 
@@ -1591,6 +1618,7 @@ def geom_hex(mapping=None, *, data=None, stat=None, position=None, show_legend=N
1591
1618
  def geom_tile(mapping=None, *, data=None, stat=None, position=None, show_legend=None, inherit_aes=None,
1592
1619
  manual_key=None, sampling=None,
1593
1620
  tooltips=None,
1621
+ width_unit=None, height_unit=None,
1594
1622
  color_by=None, fill_by=None,
1595
1623
  **other_args):
1596
1624
  """
@@ -1625,6 +1653,24 @@ def geom_tile(mapping=None, *, data=None, stat=None, position=None, show_legend=
1625
1653
  Result of the call to the `layer_tooltips()` function.
1626
1654
  Specify appearance, style and content.
1627
1655
  Set tooltips='none' to hide tooltips from the layer.
1656
+ width_unit : {'res', 'identity', 'size', 'px'}, default='res'
1657
+ Unit for width of the tile.
1658
+ Possible values:
1659
+
1660
+ - 'res': the unit equals the smallest distance between adjacent tiles along the corresponding axis;
1661
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
1662
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
1663
+ - 'px': the unit is measured in screen pixels.
1664
+
1665
+ height_unit : {'res', 'identity', 'size', 'px'}, default='res'
1666
+ Unit for height of the tile.
1667
+ Possible values:
1668
+
1669
+ - 'res': the unit equals the smallest distance between adjacent tiles along the corresponding axis;
1670
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
1671
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
1672
+ - 'px': the unit is measured in screen pixels.
1673
+
1628
1674
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
1629
1675
  Define the color aesthetic for the geometry.
1630
1676
  fill_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='fill'
@@ -1736,6 +1782,8 @@ def geom_tile(mapping=None, *, data=None, stat=None, position=None, show_legend=
1736
1782
  manual_key=manual_key,
1737
1783
  sampling=sampling,
1738
1784
  tooltips=tooltips,
1785
+ width_unit=width_unit,
1786
+ height_unit=height_unit,
1739
1787
  color_by=color_by, fill_by=fill_by,
1740
1788
  **other_args)
1741
1789
 
@@ -1838,6 +1886,7 @@ def geom_raster(mapping=None, *, data=None, stat=None, position=None, show_legen
1838
1886
  def geom_errorbar(mapping=None, *, data=None, stat=None, position=None, show_legend=None, inherit_aes=None,
1839
1887
  manual_key=None,
1840
1888
  sampling=None, tooltips=None,
1889
+ width_unit=None,
1841
1890
  color_by=None,
1842
1891
  **other_args):
1843
1892
  """
@@ -1877,6 +1926,15 @@ def geom_errorbar(mapping=None, *, data=None, stat=None, position=None, show_leg
1877
1926
  Result of the call to the `layer_tooltips()` function.
1878
1927
  Specify appearance, style and content.
1879
1928
  Set tooltips='none' to hide tooltips from the layer.
1929
+ width_unit : {'res', 'identity', 'size', 'px'}, default='res'
1930
+ Unit for the whisker width of the error bar.
1931
+ Possible values:
1932
+
1933
+ - 'res': the unit equals the smallest distance between adjacent error bars along the corresponding axis;
1934
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
1935
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
1936
+ - 'px': the unit is measured in screen pixels.
1937
+
1880
1938
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
1881
1939
  Define the color aesthetic for the geometry.
1882
1940
  other_args
@@ -1903,7 +1961,7 @@ def geom_errorbar(mapping=None, *, data=None, stat=None, position=None, show_leg
1903
1961
  - alpha : transparency level of a layer. Accept values between 0 and 1.
1904
1962
  - color (colour) : color of the geometry lines. For more info see `Color and Fill <https://lets-plot.org/python/pages/aesthetics.html#color-and-fill>`__.
1905
1963
  - size : line width. Define bar line width.
1906
- - width or height : size of the whiskers of vertical or horizontal bar, respectively. Typically range between 0 and 1. Values that are greater than 1 lead to overlapping of the bars.
1964
+ - width : size of the whiskers of error bar. Typically range between 0 and 1. Values that are greater than 1 lead to overlapping of the bars.
1907
1965
  - linetype : type of the line. Accept codes or names (0 = 'blank', 1 = 'solid', 2 = 'dashed', 3 = 'dotted', 4 = 'dotdash', 5 = 'longdash', 6 = 'twodash'), a hex string (up to 8 digits for dash-gap lengths), or a list pattern [offset, [dash, gap, ...]] / [dash, gap, ...]. For more info see `Line Types <https://lets-plot.org/python/pages/aesthetics.html#line-types>`__.
1908
1966
 
1909
1967
  ----
@@ -1965,9 +2023,22 @@ def geom_errorbar(mapping=None, *, data=None, stat=None, position=None, show_leg
1965
2023
  'c': ['gr1', 'gr2', 'gr1', 'gr2']
1966
2024
  }
1967
2025
  ggplot(data) + \\
1968
- geom_errorbar(aes(y='y', xmin='xmin', xmax='xmax', color='c'), height=0.1, size=2)
2026
+ geom_errorbar(aes(y='y', xmin='xmin', xmax='xmax', color='c'), width=0.1, size=2)
1969
2027
 
1970
2028
  """
2029
+ if mapping is not None and 'height' in mapping.props():
2030
+ print("WARN: using 'height' aesthetic parameter for errorbar was deprecated.\n"
2031
+ " Please, use 'width' aesthetic instead.")
2032
+ mapping.props()['width'] = mapping.props().pop('height')
2033
+ if 'height' in other_args:
2034
+ print("WARN: using 'height' parameter for errorbar was deprecated.\n"
2035
+ " Please, use 'width' parameter instead.")
2036
+ other_args['width'] = other_args.pop('height')
2037
+ if 'height_unit' in other_args:
2038
+ print("WARN: using 'height_unit' parameter for errorbar was deprecated.\n"
2039
+ " Please, use 'width_unit' parameter instead.")
2040
+ other_args.pop('height_unit')
2041
+
1971
2042
  return _geom('errorbar',
1972
2043
  mapping=mapping,
1973
2044
  data=data,
@@ -1978,6 +2049,7 @@ def geom_errorbar(mapping=None, *, data=None, stat=None, position=None, show_leg
1978
2049
  manual_key=manual_key,
1979
2050
  sampling=sampling,
1980
2051
  tooltips=tooltips,
2052
+ width_unit=width_unit,
1981
2053
  color_by=color_by,
1982
2054
  **other_args)
1983
2055
 
@@ -1985,6 +2057,7 @@ def geom_errorbar(mapping=None, *, data=None, stat=None, position=None, show_leg
1985
2057
  def geom_crossbar(mapping=None, *, data=None, stat=None, position=None, show_legend=None, inherit_aes=None,
1986
2058
  manual_key=None, sampling=None, tooltips=None,
1987
2059
  fatten=None,
2060
+ width_unit=None,
1988
2061
  color_by=None, fill_by=None,
1989
2062
  **other_args):
1990
2063
  """
@@ -2026,6 +2099,15 @@ def geom_crossbar(mapping=None, *, data=None, stat=None, position=None, show_leg
2026
2099
  Set tooltips='none' to hide tooltips from the layer.
2027
2100
  fatten : float, default=2.5
2028
2101
  A multiplicative factor applied to size of the middle bar.
2102
+ width_unit : {'res', 'identity', 'size', 'px'}, default='res'
2103
+ Unit for the width of the crossbar.
2104
+ Possible values:
2105
+
2106
+ - 'res': the unit equals the smallest distance between adjacent crossbars along the corresponding axis;
2107
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
2108
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
2109
+ - 'px': the unit is measured in screen pixels.
2110
+
2029
2111
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
2030
2112
  Define the color aesthetic for the geometry.
2031
2113
  fill_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='fill'
@@ -2122,6 +2204,7 @@ def geom_crossbar(mapping=None, *, data=None, stat=None, position=None, show_leg
2122
2204
  sampling=sampling,
2123
2205
  tooltips=tooltips,
2124
2206
  fatten=fatten,
2207
+ width_unit=width_unit,
2125
2208
  color_by=color_by, fill_by=fill_by,
2126
2209
  **other_args)
2127
2210
 
@@ -3552,6 +3635,7 @@ def geom_boxplot(mapping=None, *, data=None, stat=None, position=None, show_lege
3552
3635
  outlier_shape=None, outlier_size=None, outlier_stroke=None,
3553
3636
  varwidth=None,
3554
3637
  whisker_width=None,
3638
+ width_unit=None,
3555
3639
  color_by=None, fill_by=None,
3556
3640
  **other_args):
3557
3641
  """
@@ -3609,6 +3693,15 @@ def geom_boxplot(mapping=None, *, data=None, stat=None, position=None, show_lege
3609
3693
  of the number of observations in the groups.
3610
3694
  whisker_width : float, default=0.5
3611
3695
  A multiplicative factor applied to the box width to draw horizontal segments on whiskers.
3696
+ width_unit : {'res', 'identity', 'size', 'px'}, default='res'
3697
+ Unit for the width of the boxplot.
3698
+ Possible values:
3699
+
3700
+ - 'res': the unit equals the smallest distance between adjacent boxes along the corresponding axis;
3701
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
3702
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
3703
+ - 'px': the unit is measured in screen pixels.
3704
+
3612
3705
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
3613
3706
  Define the color aesthetic for the geometry.
3614
3707
  fill_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='fill'
@@ -3746,6 +3839,7 @@ def geom_boxplot(mapping=None, *, data=None, stat=None, position=None, show_lege
3746
3839
  fatten=fatten,
3747
3840
  varwidth=varwidth,
3748
3841
  whisker_width=whisker_width,
3842
+ width_unit=width_unit,
3749
3843
  color_by=color_by, fill_by=fill_by,
3750
3844
  **other_args)
3751
3845
  if stat is None or stat == 'boxplot':
@@ -4820,7 +4914,7 @@ def geom_density(mapping=None, *, data=None, stat=None, position=None, show_lege
4820
4914
 
4821
4915
  .. jupyter-execute::
4822
4916
  :linenos:
4823
- :emphasize-lines: 11
4917
+ :emphasize-lines: 10-11
4824
4918
 
4825
4919
  import numpy as np
4826
4920
  from lets_plot import *
@@ -4837,14 +4931,13 @@ def geom_density(mapping=None, *, data=None, stat=None, position=None, show_lege
4837
4931
  for bw in bandwidths
4838
4932
  for n in sample_sizes
4839
4933
  ]
4840
-
4841
4934
  gggrid(plots, ncol=3) + ggsize(900, 600)
4842
4935
 
4843
4936
  |
4844
4937
 
4845
4938
  .. jupyter-execute::
4846
4939
  :linenos:
4847
- :emphasize-lines: 10-11
4940
+ :emphasize-lines: 10-12
4848
4941
 
4849
4942
  import numpy as np
4850
4943
  from lets_plot import *
@@ -4855,12 +4948,12 @@ def geom_density(mapping=None, *, data=None, stat=None, position=None, show_lege
4855
4948
  p = ggplot({'x': x, 'y': y}, aes(x='x'))
4856
4949
  adjustments = [0.5 * (1 + i) for i in range(3)]
4857
4950
  plots = [
4858
- p + geom_density(aes(weight='y'),
4951
+ p + geom_density(
4952
+ aes(weight='y'),
4859
4953
  kernel='cosine', adjust=adjust
4860
4954
  ) + ggtitle(f'adjust={adjust}')
4861
4955
  for adjust in adjustments
4862
4956
  ]
4863
-
4864
4957
  gggrid(plots) + ggsize(800, 200)
4865
4958
 
4866
4959
  """
@@ -4894,10 +4987,6 @@ def geom_density2d(mapping=None, *, data=None, stat=None, position=None, show_le
4894
4987
  """
4895
4988
  Display density function contour.
4896
4989
 
4897
- By default, this geom uses `coord_fixed()`.
4898
- However, this may not be the best choice when the values on the X/Y axis have significantly different magnitudes.
4899
- In such cases, try using `coord_cartesian()`.
4900
-
4901
4990
  Parameters
4902
4991
  ----------
4903
4992
  mapping : `FeatureSpec`
@@ -5021,7 +5110,7 @@ def geom_density2d(mapping=None, *, data=None, stat=None, position=None, show_le
5021
5110
 
5022
5111
  .. jupyter-execute::
5023
5112
  :linenos:
5024
- :emphasize-lines: 13
5113
+ :emphasize-lines: 12-14
5025
5114
 
5026
5115
  import numpy as np
5027
5116
  from lets_plot import *
@@ -5034,20 +5123,20 @@ def geom_density2d(mapping=None, *, data=None, stat=None, position=None, show_le
5034
5123
  bandwidths = [0.2, 0.4]
5035
5124
  sample_sizes = [16, 256]
5036
5125
  plots = [
5037
- p + geom_density2d(kernel='epanechikov',
5038
- bw=bw, n=n
5126
+ p + geom_density2d(
5127
+ kernel='epanechikov',
5128
+ bw=bw, n=n
5039
5129
  ) + ggtitle(f'bw={bw}, n={n}')
5040
5130
  for bw in bandwidths
5041
5131
  for n in sample_sizes
5042
5132
  ]
5043
-
5044
5133
  gggrid(plots, ncol=2) + ggsize(600, 650)
5045
5134
 
5046
5135
  |
5047
5136
 
5048
5137
  .. jupyter-execute::
5049
5138
  :linenos:
5050
- :emphasize-lines: 13-14
5139
+ :emphasize-lines: 12-15
5051
5140
 
5052
5141
  import numpy as np
5053
5142
  from lets_plot import *
@@ -5060,14 +5149,14 @@ def geom_density2d(mapping=None, *, data=None, stat=None, position=None, show_le
5060
5149
  adjustments = [1.5, 2.5]
5061
5150
  bin_counts = [5, 15]
5062
5151
  plots = [
5063
- p + geom_density2d(kernel='cosine',
5152
+ p + geom_density2d(
5153
+ kernel='cosine',
5064
5154
  adjust=adjust,
5065
5155
  bins=bins
5066
5156
  ) + ggtitle(f'adjust={adjust}, bins={bins}')
5067
5157
  for adjust in adjustments
5068
5158
  for bins in bin_counts
5069
5159
  ]
5070
-
5071
5160
  gggrid(plots, ncol=2) + ggsize(600, 650)
5072
5161
 
5073
5162
  |
@@ -5085,7 +5174,7 @@ def geom_density2d(mapping=None, *, data=None, stat=None, position=None, show_le
5085
5174
  y = np.random.normal(size=n)
5086
5175
  ggplot({'x': x, 'y': y}, aes('x', 'y')) + \\
5087
5176
  geom_raster(aes(fill='..density..'), \\
5088
- stat='density2d', contour=False, n=50) + \\
5177
+ stat='density2d', contour=False, n=50) + \\
5089
5178
  scale_fill_gradient(low='#49006a', high='#fff7f3')
5090
5179
 
5091
5180
  |
@@ -5134,10 +5223,6 @@ def geom_density2df(mapping=None, *, data=None, stat=None, position=None, show_l
5134
5223
  """
5135
5224
  Fill density function contour.
5136
5225
 
5137
- By default, this geom uses `coord_fixed()`.
5138
- However, this may not be the best choice when the values on the X/Y axis have significantly different magnitudes.
5139
- In such cases, try using `coord_cartesian()`.
5140
-
5141
5226
  Parameters
5142
5227
  ----------
5143
5228
  mapping : `FeatureSpec`
@@ -5255,7 +5340,7 @@ def geom_density2df(mapping=None, *, data=None, stat=None, position=None, show_l
5255
5340
 
5256
5341
  .. jupyter-execute::
5257
5342
  :linenos:
5258
- :emphasize-lines: 13
5343
+ :emphasize-lines: 12-15
5259
5344
 
5260
5345
  import numpy as np
5261
5346
  from lets_plot import *
@@ -5268,8 +5353,10 @@ def geom_density2df(mapping=None, *, data=None, stat=None, position=None, show_l
5268
5353
  bandwidths = [0.2, 0.4]
5269
5354
  sample_sizes = [16, 256]
5270
5355
  plots = [
5271
- p + geom_density2df(kernel='epanechikov', size=.5, color='white',
5272
- bw=bw, n=n
5356
+ p + geom_density2df(
5357
+ kernel='epanechikov',
5358
+ size=.5, color='white',
5359
+ bw=bw, n=n
5273
5360
  ) + ggtitle(f'bw={bw}, n={n}')
5274
5361
  for bw in bandwidths
5275
5362
  for n in sample_sizes
@@ -5280,7 +5367,7 @@ def geom_density2df(mapping=None, *, data=None, stat=None, position=None, show_l
5280
5367
 
5281
5368
  .. jupyter-execute::
5282
5369
  :linenos:
5283
- :emphasize-lines: 12-14
5370
+ :emphasize-lines: 12-15
5284
5371
 
5285
5372
  import numpy as np
5286
5373
  from lets_plot import *
@@ -5293,14 +5380,14 @@ def geom_density2df(mapping=None, *, data=None, stat=None, position=None, show_l
5293
5380
  adjustments = [1.5, 2.5]
5294
5381
  bin_counts = [5, 15]
5295
5382
  plots = [
5296
- p + geom_density2df(kernel='cosine', size=.5, color='white',
5383
+ p + geom_density2df(
5384
+ kernel='cosine', size=.5, color='white',
5297
5385
  adjust=adjust,
5298
5386
  bins=bins
5299
5387
  ) + ggtitle(f'adjust={adjust}, bins={bins}')
5300
5388
  for adjust in adjustments
5301
5389
  for bins in bin_counts
5302
5390
  ]
5303
-
5304
5391
  gggrid(plots, ncol=2) + ggsize(600, 650)
5305
5392
 
5306
5393
  |
@@ -6482,7 +6569,7 @@ def geom_segment(mapping=None, *, data=None, stat=None, position=None, show_lege
6482
6569
  geodesic : bool, default=False
6483
6570
  Draw geodesic. Coordinates expected to be in WGS84. Works only with `geom_livemap()`.
6484
6571
  spacer : float, default=0.0
6485
- Space to shorten a segment by moving the start/end.
6572
+ Pixels to shorten segment, creating gaps at start/end points.
6486
6573
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
6487
6574
  Define the color aesthetic for the geometry.
6488
6575
  other_args
@@ -6649,7 +6736,7 @@ def geom_curve(mapping=None, *, data=None, stat=None, position=None, show_legend
6649
6736
  ncp : int, default=5
6650
6737
  The number of control points used to draw the curve. More control points creates a smoother curve.
6651
6738
  spacer : float, default=0.0
6652
- Space to shorten a curve by moving the start/end.
6739
+ Pixels to shorten segment, creating gaps at start/end points.
6653
6740
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
6654
6741
  Define the color aesthetic for the geometry.
6655
6742
  other_args
@@ -6900,6 +6987,7 @@ def geom_text(mapping=None, *, data=None, stat=None, position=None, show_legend=
6900
6987
  na_text=None,
6901
6988
  nudge_x=None, nudge_y=None,
6902
6989
  size_unit=None,
6990
+ nudge_unit=None,
6903
6991
  check_overlap=None,
6904
6992
  color_by=None,
6905
6993
  **other_args):
@@ -6969,6 +7057,14 @@ def geom_text(mapping=None, *, data=None, stat=None, position=None, show_legend=
6969
7057
  size_unit : {'x', 'y'}
6970
7058
  Relate the size of the text to the length of the unit step along one of the axes.
6971
7059
  If None, no fitting is performed.
7060
+ nudge_unit : {'identity', 'size', 'px'}, default='identity'
7061
+ Units for x and y nudging.
7062
+ Possible values:
7063
+
7064
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
7065
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
7066
+ - 'px': the unit is measured in screen pixels.
7067
+
6972
7068
  check_overlap : bool, default=False
6973
7069
  If True, skip plotting text that overlaps previous text in the same layer.
6974
7070
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
@@ -7121,6 +7217,7 @@ def geom_text(mapping=None, *, data=None, stat=None, position=None, show_legend=
7121
7217
  na_text=na_text,
7122
7218
  nudge_x=nudge_x, nudge_y=nudge_y,
7123
7219
  size_unit=size_unit,
7220
+ nudge_unit=nudge_unit,
7124
7221
  check_overlap=check_overlap,
7125
7222
  color_by=color_by,
7126
7223
  **other_args)
@@ -7136,6 +7233,7 @@ def geom_label(mapping=None, *, data=None, stat=None, position=None, show_legend
7136
7233
  label_padding=None, label_r=None, label_size=None,
7137
7234
  alpha_stroke=None,
7138
7235
  size_unit=None,
7236
+ nudge_unit=None,
7139
7237
  check_overlap=None,
7140
7238
  color_by=None, fill_by=None,
7141
7239
  **other_args):
@@ -7213,6 +7311,14 @@ def geom_label(mapping=None, *, data=None, stat=None, position=None, show_legend
7213
7311
  size_unit : {'x', 'y'}
7214
7312
  Relate the size of the text label to the length of the unit step along one of the axes.
7215
7313
  If None, no fitting is performed.
7314
+ nudge_unit : {'identity', 'size', 'px'}, default='identity'
7315
+ Units for x and y nudging.
7316
+ Possible values:
7317
+
7318
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
7319
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
7320
+ - 'px': the unit is measured in screen pixels.
7321
+
7216
7322
  check_overlap : bool, default=False
7217
7323
  If True, skip plotting text that overlaps previous text in the same layer.
7218
7324
  color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
@@ -7373,6 +7479,7 @@ def geom_label(mapping=None, *, data=None, stat=None, position=None, show_legend
7373
7479
  label_size=label_size,
7374
7480
  alpha_stroke=alpha_stroke,
7375
7481
  size_unit=size_unit,
7482
+ nudge_unit=nudge_unit,
7376
7483
  check_overlap=check_overlap,
7377
7484
  color_by=color_by, fill_by=fill_by,
7378
7485
  **other_args)
@@ -7385,6 +7492,7 @@ def geom_pie(mapping=None, *, data=None, stat=None, position=None, show_legend=N
7385
7492
  hole=None,
7386
7493
  stroke_side=None,
7387
7494
  spacer_width=None, spacer_color=None,
7495
+ start=None, direction=None,
7388
7496
  size_unit=None,
7389
7497
  color_by=None, fill_by=None,
7390
7498
  **other_args):
@@ -7442,10 +7550,15 @@ def geom_pie(mapping=None, *, data=None, stat=None, position=None, show_legend=N
7442
7550
  stroke_side : {'outer', 'inner', 'both'}, default='both'
7443
7551
  Define which arcs of pie sector should have a stroke.
7444
7552
  spacer_width : float, default=0.75
7445
- Line width between sectors.
7553
+ Line width between sectors in pixels.
7446
7554
  Spacers are not applied to exploded sectors and to sides of adjacent sectors.
7447
7555
  spacer_color : str
7448
7556
  Color for spacers between sectors. By default, the "paper" color is used.
7557
+ start : float, default=None
7558
+ Specify the angle at which the first sector starts. Accept values between 0 and 360.
7559
+ Default is a negative angle of the first sector.
7560
+ direction : {1, -1}, default=1
7561
+ Specify angle direction, 1=clockwise, -1=counter-clockwise.
7449
7562
  size_unit : {'x', 'y'}
7450
7563
  Relate the size of the pie chart to the length of the unit step along one of the axes.
7451
7564
  If None, no fitting is performed.
@@ -7625,6 +7738,7 @@ def geom_pie(mapping=None, *, data=None, stat=None, position=None, show_legend=N
7625
7738
  stroke_side=stroke_side,
7626
7739
  spacer_width=spacer_width,
7627
7740
  spacer_color=spacer_color,
7741
+ start=start, direction=direction,
7628
7742
  size_unit=size_unit,
7629
7743
  color_by=color_by, fill_by=fill_by,
7630
7744
  **other_args)
lets_plot/plot/pos.py CHANGED
@@ -146,7 +146,7 @@ def position_jitter(width=None, height=None, seed=None):
146
146
  return _pos('jitter', width=width, height=height, seed=seed)
147
147
 
148
148
 
149
- def position_nudge(x=None, y=None):
149
+ def position_nudge(x=None, y=None, unit=None):
150
150
  """
151
151
  Adjust position by nudging a given offset.
152
152
 
@@ -156,6 +156,13 @@ def position_nudge(x=None, y=None):
156
156
  Nudging width.
157
157
  y : float
158
158
  Nudging height.
159
+ unit : {'identity', 'size', 'px'}, default='identity'
160
+ Units for x and y nudging.
161
+ Possible values:
162
+
163
+ - 'identity': a unit of 1 corresponds to a difference of 1 in data space;
164
+ - 'size': a unit of 1 corresponds to the diameter of a point with `size=1`;
165
+ - 'px': the unit is measured in screen pixels.
159
166
 
160
167
  Returns
161
168
  -------
@@ -182,10 +189,10 @@ def position_nudge(x=None, y=None):
182
189
  t = np.random.choice(list('abcdefghijk'), size=n)
183
190
  ggplot({'x': x, 'y': y, 't': t}, aes('x', 'y')) + \\
184
191
  geom_point(size=5, shape=21, color='black', fill='red') + \\
185
- geom_text(aes(label='t'), position=position_nudge(y=.05))
192
+ geom_text(aes(label='t'), position=position_nudge(y=.05, unit='identity'))
186
193
 
187
194
  """
188
- return _pos('nudge', x=x, y=y)
195
+ return _pos('nudge', x=x, y=y, unit=unit)
189
196
 
190
197
 
191
198
  def position_jitterdodge(dodge_width=None, jitter_width=None, jitter_height=None, seed=None):
lets_plot/plot/scale.py CHANGED
@@ -741,18 +741,18 @@ def scale_continuous(aesthetic, *,
741
741
 
742
742
  .. jupyter-execute::
743
743
  :linenos:
744
- :emphasize-lines: 10
744
+ :emphasize-lines: 9
745
745
 
746
746
  from lets_plot import *
747
747
  LetsPlot.setup_html()
748
-
749
- d = {
748
+ data = {
750
749
  'x': [0, 1, 2],
751
750
  'y': [0, 1, 2]
752
751
  }
753
- ggplot(d) + \\
752
+ ggplot(data) + \\
754
753
  geom_point(aes(x='x', y='y'), size=15) + \\
755
754
  scale_continuous(['x','y'], expand=[0, 0]) # no expansion - points right on the edges
755
+
756
756
  """
757
757
  if _is_color_scale(aesthetic):
758
758
  scale_mapper_kind = 'color_gradient' if scale_mapper_kind is None else scale_mapper_kind
@@ -2027,18 +2027,18 @@ def scale_discrete(aesthetic, *,
2027
2027
 
2028
2028
  .. jupyter-execute::
2029
2029
  :linenos:
2030
- :emphasize-lines: 10
2030
+ :emphasize-lines: 9
2031
2031
 
2032
2032
  from lets_plot import *
2033
2033
  LetsPlot.setup_html()
2034
-
2035
- d = {
2034
+ data = {
2036
2035
  'x': [0, 1, 2],
2037
2036
  'y': [0, 1, 2]
2038
2037
  }
2039
- ggplot(d) + \\
2038
+ ggplot(data) + \\
2040
2039
  geom_point(aes(x='x', y='y'), size=15) + \\
2041
2040
  scale_discrete(['x','y'], expand=[0, 0]) # no expansion - points right on the edges
2041
+
2042
2042
  """
2043
2043
  return _scale(aesthetic=aesthetic,
2044
2044
  name=name,