ggh4x-python 0.3.1.9000__py3-none-any.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.
Files changed (64) hide show
  1. ggh4x/__init__.py +140 -0
  2. ggh4x/_aimed_text_grob.py +432 -0
  3. ggh4x/_borrowed_ggplot2.py +273 -0
  4. ggh4x/_cli.py +84 -0
  5. ggh4x/_datasets.py +106 -0
  6. ggh4x/_download.py +111 -0
  7. ggh4x/_facet_helpers.py +313 -0
  8. ggh4x/_facet_utils.py +649 -0
  9. ggh4x/_gap_grobs.py +606 -0
  10. ggh4x/_registry.py +10 -0
  11. ggh4x/_rlang.py +93 -0
  12. ggh4x/_utils.py +150 -0
  13. ggh4x/_vctrs.py +233 -0
  14. ggh4x/conveniences.py +601 -0
  15. ggh4x/coord_axes_inside.py +380 -0
  16. ggh4x/element_part_rect.py +545 -0
  17. ggh4x/facet_grid2.py +1018 -0
  18. ggh4x/facet_manual.py +901 -0
  19. ggh4x/facet_nested.py +776 -0
  20. ggh4x/facet_nested_wrap.py +193 -0
  21. ggh4x/facet_wrap2.py +896 -0
  22. ggh4x/geom_box.py +536 -0
  23. ggh4x/geom_outline_point.py +444 -0
  24. ggh4x/geom_pointpath.py +259 -0
  25. ggh4x/geom_polygonraster.py +252 -0
  26. ggh4x/geom_rectrug.py +489 -0
  27. ggh4x/geom_text_aimed.py +279 -0
  28. ggh4x/guide_stringlegend.py +354 -0
  29. ggh4x/help_secondary.py +549 -0
  30. ggh4x/multiscale/__init__.py +51 -0
  31. ggh4x/multiscale/_multiscale_add.py +207 -0
  32. ggh4x/multiscale/scale_listed.py +167 -0
  33. ggh4x/multiscale/scale_manual.py +478 -0
  34. ggh4x/multiscale/scale_multi.py +393 -0
  35. ggh4x/panel_scales/__init__.py +58 -0
  36. ggh4x/panel_scales/at_panel.py +115 -0
  37. ggh4x/panel_scales/facetted_pos_scales.py +647 -0
  38. ggh4x/panel_scales/force_panelsize.py +411 -0
  39. ggh4x/panel_scales/scale_facet.py +222 -0
  40. ggh4x/position_disjoint_ranges.py +229 -0
  41. ggh4x/position_lineartrans.py +242 -0
  42. ggh4x/py.typed +0 -0
  43. ggh4x/resources/faithful.csv +273 -0
  44. ggh4x/resources/iris.csv +151 -0
  45. ggh4x/resources/mtcars.csv +33 -0
  46. ggh4x/resources/pressure.csv +20 -0
  47. ggh4x/resources/volcano.csv +87 -0
  48. ggh4x/save.py +255 -0
  49. ggh4x/stat_difference.py +388 -0
  50. ggh4x/stat_funxy.py +436 -0
  51. ggh4x/stat_rle.py +290 -0
  52. ggh4x/stat_rollingkernel.py +369 -0
  53. ggh4x/stat_theodensity.py +681 -0
  54. ggh4x/strip_nested.py +448 -0
  55. ggh4x/strip_split.py +687 -0
  56. ggh4x/strip_tag.py +636 -0
  57. ggh4x/strip_themed.py +232 -0
  58. ggh4x/strip_vanilla.py +1464 -0
  59. ggh4x/themes.py +31 -0
  60. ggh4x/themes_ggh4x.py +67 -0
  61. ggh4x_python-0.3.1.9000.dist-info/METADATA +40 -0
  62. ggh4x_python-0.3.1.9000.dist-info/RECORD +64 -0
  63. ggh4x_python-0.3.1.9000.dist-info/WHEEL +4 -0
  64. ggh4x_python-0.3.1.9000.dist-info/licenses/LICENSE +3 -0
@@ -0,0 +1,193 @@
1
+ """Nested-strip wrapped facets (port of ggh4x ``R/facet_nested_wrap.R``).
2
+
3
+ ``facet_nested_wrap()`` wraps a sequence of panels onto a 2-D layout (like
4
+ :func:`ggh4x.facet_wrap2`) and merges grouped strips where they fall in the same
5
+ row / column, drawing hierarchy ``nest_line``s between strip layers.
6
+
7
+ The :class:`FacetNestedWrap` ggproto subclasses
8
+ :class:`ggh4x.facet_wrap2.FacetWrap2` and overrides a single seam --
9
+ :meth:`FacetNestedWrap.finish_panels` -- which delegates to the shared
10
+ :func:`ggh4x.facet_nested.add_nest_indicator` helper (identical to
11
+ ``FacetNested``). Everything else (layout, axes, the label-merging strip) is
12
+ inherited.
13
+
14
+ The default strip is :func:`ggh4x.strip_nested.strip_nested`, matching R's
15
+ ``strip = "nested"``.
16
+
17
+ R source: ``ggh4x/R/facet_nested_wrap.R``.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import warnings
23
+ from typing import Any, Dict, Optional
24
+
25
+ import pandas as pd
26
+
27
+ from grid_py import Unit
28
+
29
+ from ggh4x.facet_nested import _coerce_nest_line, add_nest_indicator
30
+ from ggh4x.facet_wrap2 import FacetWrap2, new_wrap_facets
31
+ from ggh4x.strip_nested import strip_nested
32
+
33
+ # Importing this module registers the ``ggh4x.facet.nestline`` theme element.
34
+ import ggh4x.themes_ggh4x # noqa: F401
35
+
36
+ __all__ = [
37
+ "facet_nested_wrap",
38
+ "FacetNestedWrap",
39
+ ]
40
+
41
+
42
+ # ---------------------------------------------------------------------------
43
+ # Constructor
44
+ # ---------------------------------------------------------------------------
45
+ def facet_nested_wrap(
46
+ facets: Any,
47
+ nrow: Optional[int] = None,
48
+ ncol: Optional[int] = None,
49
+ scales: Any = "fixed",
50
+ axes: Any = "margins",
51
+ remove_labels: Any = "none",
52
+ shrink: bool = True,
53
+ labeller: Any = "label_value",
54
+ as_table: bool = True,
55
+ drop: bool = True,
56
+ dir: str = "h",
57
+ strip_position: str = "top",
58
+ nest_line: Any = None,
59
+ solo_line: bool = False,
60
+ resect: Any = None,
61
+ trim_blank: bool = True,
62
+ strip: Any = strip_nested,
63
+ bleed: Optional[bool] = None,
64
+ ) -> "FacetNestedWrap":
65
+ """Ribbon of panels with nested strips.
66
+
67
+ Port of ggh4x's ``facet_nested_wrap()`` (``R/facet_nested_wrap.R:49-101``).
68
+ Inherits the capabilities of :func:`ggh4x.facet_wrap2` and adds label-merged
69
+ nested strips (merged only within the same wrap row / column) plus hierarchy
70
+ ``nest_line``s.
71
+
72
+ Parameters
73
+ ----------
74
+ facets : formula / list / dict
75
+ Faceting variables. Variable order encodes the hierarchy (first =
76
+ outermost).
77
+ nrow, ncol : int or None
78
+ scales : {"fixed", "free_x", "free_y", "free"} or bool, default "fixed"
79
+ axes : {"margins", "x", "y", "all"} or bool, default "margins"
80
+ remove_labels : {"none", "x", "y", "all"} or bool, default "none"
81
+ shrink : bool, default True
82
+ labeller : callable or str, default "label_value"
83
+ as_table : bool, default True
84
+ drop : bool, default True
85
+ dir : {"h", "v"}, default "h"
86
+ strip_position : {"top", "bottom", "left", "right"}, default "top"
87
+ nest_line : ElementLine / ElementBlank / bool / None, default None
88
+ Hierarchy line element; see :func:`ggh4x.facet_nested.facet_nested`.
89
+ solo_line : bool, default False
90
+ Draw nest lines on single-child parent strips too.
91
+ resect : Unit or None, default None
92
+ How much to shorten each nest line at both ends (``None`` -> ``0 mm``).
93
+ trim_blank : bool, default True
94
+ When ``False``, ``nrow``/``ncol`` are taken literally.
95
+ strip : Strip or callable or str, default :func:`ggh4x.strip_nested.strip_nested`
96
+ bleed : bool or None, default None
97
+ Deprecated; forwards to ``strip_nested(bleed=...)`` with a warning.
98
+
99
+ Returns
100
+ -------
101
+ FacetNestedWrap
102
+ A ggproto facet object that can be added to a plot.
103
+ """
104
+ from ggh4x.strip_vanilla import resolve_strip
105
+
106
+ strip = resolve_strip(strip)
107
+ if bleed is not None:
108
+ warnings.warn(
109
+ "The `bleed` argument of `facet_nested_wrap()` is deprecated as of "
110
+ "ggh4x 0.2.0. The `bleed` argument should be set in the "
111
+ "`strip_nested()` function instead.",
112
+ DeprecationWarning,
113
+ stacklevel=2,
114
+ )
115
+ strip.params["bleed"] = bool(bleed)
116
+
117
+ nest_line = _coerce_nest_line(nest_line)
118
+ if resect is None:
119
+ resect = Unit(0, "mm")
120
+
121
+ params = {
122
+ "nest_line": nest_line,
123
+ "solo_line": bool(solo_line),
124
+ "resect": resect,
125
+ }
126
+
127
+ return new_wrap_facets(
128
+ facets,
129
+ nrow,
130
+ ncol,
131
+ scales,
132
+ axes,
133
+ remove_labels,
134
+ shrink,
135
+ labeller,
136
+ as_table,
137
+ drop,
138
+ dir,
139
+ strip_position,
140
+ strip,
141
+ trim_blank,
142
+ params=params,
143
+ super_=FacetNestedWrap,
144
+ )
145
+
146
+
147
+ # ---------------------------------------------------------------------------
148
+ # ggproto
149
+ # ---------------------------------------------------------------------------
150
+ class FacetNestedWrap(FacetWrap2):
151
+ """Nested-strip wrapped facet ggproto (port of R ``FacetNestedWrap``).
152
+
153
+ Subclasses :class:`ggh4x.facet_wrap2.FacetWrap2`. Only overrides
154
+ ``finish_panels`` to draw the nest indicator lines via
155
+ :func:`ggh4x.facet_nested.add_nest_indicator`; everything else is inherited.
156
+
157
+ Attributes
158
+ ----------
159
+ shrink : bool
160
+ strip : Strip
161
+ Defaults to a :class:`ggh4x.strip_nested.StripNested`.
162
+ params : dict
163
+ Adds ``nest_line``, ``solo_line``, ``resect`` to the ``FacetWrap2`` params.
164
+ """
165
+
166
+ _class_name = "FacetNestedWrap"
167
+
168
+ def finish_panels(
169
+ self,
170
+ panels: Any,
171
+ layout: pd.DataFrame,
172
+ params: Dict[str, Any],
173
+ theme: Any,
174
+ ) -> Any:
175
+ """Draw the nest indicator lines onto the assembled panel table.
176
+
177
+ Port of R ``FacetNestedWrap$finish_panels`` (``facet_nested_wrap.R:111-113``);
178
+ delegates to :func:`ggh4x.facet_nested.add_nest_indicator`.
179
+
180
+ Parameters
181
+ ----------
182
+ panels : Gtable
183
+ The assembled panel gtable.
184
+ layout : pandas.DataFrame
185
+ params : dict
186
+ theme : Theme
187
+
188
+ Returns
189
+ -------
190
+ Gtable
191
+ The panel gtable with nest-line ``"nester"`` grobs added.
192
+ """
193
+ return add_nest_indicator(panels, params, theme)