gsplot 0.1.1__tar.gz → 0.1.3__tar.gz

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 (36) hide show
  1. {gsplot-0.1.1 → gsplot-0.1.3}/PKG-INFO +5 -4
  2. {gsplot-0.1.1 → gsplot-0.1.3}/README.md +3 -2
  3. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/__init__.py +6 -3
  4. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/data/load_file.py +144 -1
  5. gsplot-0.1.3/gsplot/figure/axes_base.py +145 -0
  6. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/figure/axes_inset.py +1 -11
  7. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/plot/scatter.py +1 -3
  8. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/style/label.py +129 -40
  9. gsplot-0.1.3/gsplot/style/title.py +122 -0
  10. gsplot-0.1.3/gsplot/version.py +2 -0
  11. {gsplot-0.1.1 → gsplot-0.1.3}/pyproject.toml +1 -1
  12. gsplot-0.1.1/gsplot/figure/axes_base.py +0 -288
  13. gsplot-0.1.1/gsplot/version.py +0 -2
  14. {gsplot-0.1.1 → gsplot-0.1.3}/LICENSE +0 -0
  15. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/base/base.py +0 -0
  16. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/base/base_alias_validator.py +0 -0
  17. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/color/colormap.py +0 -0
  18. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/config/config.py +0 -0
  19. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/figure/axes.py +0 -0
  20. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/figure/axes_range_base.py +0 -0
  21. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/figure/figure_tools.py +0 -0
  22. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/figure/show.py +0 -0
  23. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/figure/store.py +0 -0
  24. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/hello_world/hello_world.py +0 -0
  25. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/logger.py +0 -0
  26. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/path/path.py +0 -0
  27. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/plot/line.py +0 -0
  28. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/plot/line_base.py +0 -0
  29. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/plot/line_colormap_base.py +0 -0
  30. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/plot/line_colormap_dashed.py +0 -0
  31. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/plot/line_colormap_solid.py +0 -0
  32. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/plot/scatter_colormap.py +0 -0
  33. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/style/graph.py +0 -0
  34. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/style/legend.py +0 -0
  35. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/style/legend_colormap.py +0 -0
  36. {gsplot-0.1.1 → gsplot-0.1.3}/gsplot/style/ticks.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: gsplot
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: General-scientific plot based on matplotlib
5
5
  Author: Giordano Mattoni
6
6
  Author-email: mattoni@scphys.kyoto-u.ac.jp
@@ -26,6 +26,7 @@ Description-Content-Type: text/markdown
26
26
  ![Using Poetry](https://img.shields.io/badge/Using-Poetry-blue)
27
27
  ![PyPI](https://img.shields.io/pypi/v/gsplot)
28
28
  ![PyPI - Downloads](https://img.shields.io/pypi/dm/gsplot)
29
+ [![PyPI Downloads](https://static.pepy.tech/badge/gsplot)](https://pepy.tech/projects/gsplot)
29
30
  ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
30
31
  ![License: MIT](https://img.shields.io/badge/License-MIT-green)
31
32
 
@@ -51,7 +52,7 @@ Welcome to **gsplot** (General-Scientific Plot), a toolkit designed to elevate c
51
52
 
52
53
  ### 📈 Example using gsplot
53
54
 
54
- [See more details](https://soichiroyamane.github.io/gsplot/guides/stable/demo/4_paper_plot.html)
55
+ [See more details](https://soichiroyamane.github.io/gsplot/stable/guides/demo/4_paper_plot.html)
55
56
 
56
57
  ![example](docs/_static/tutorial/SC_cal.png)
57
58
 
@@ -59,7 +60,7 @@ Welcome to **gsplot** (General-Scientific Plot), a toolkit designed to elevate c
59
60
 
60
61
  [See more details](https://soichiroyamane.github.io/gsplot/stable/guides/demo/13_REPL.html)
61
62
 
62
- ![repl_tutorial](./docs/_static/tutorial/repl_tutorial_sp.gif)
63
+ ![repl_tutorial](./docs/_static/tutorial/repl_tutorial_45fps.gif)
63
64
 
64
65
  ## 🚀 Getting Started
65
66
 
@@ -6,6 +6,7 @@
6
6
  ![Using Poetry](https://img.shields.io/badge/Using-Poetry-blue)
7
7
  ![PyPI](https://img.shields.io/pypi/v/gsplot)
8
8
  ![PyPI - Downloads](https://img.shields.io/pypi/dm/gsplot)
9
+ [![PyPI Downloads](https://static.pepy.tech/badge/gsplot)](https://pepy.tech/projects/gsplot)
9
10
  ![Python](https://img.shields.io/badge/python-3.10%2B-blue)
10
11
  ![License: MIT](https://img.shields.io/badge/License-MIT-green)
11
12
 
@@ -31,7 +32,7 @@ Welcome to **gsplot** (General-Scientific Plot), a toolkit designed to elevate c
31
32
 
32
33
  ### 📈 Example using gsplot
33
34
 
34
- [See more details](https://soichiroyamane.github.io/gsplot/guides/stable/demo/4_paper_plot.html)
35
+ [See more details](https://soichiroyamane.github.io/gsplot/stable/guides/demo/4_paper_plot.html)
35
36
 
36
37
  ![example](docs/_static/tutorial/SC_cal.png)
37
38
 
@@ -39,7 +40,7 @@ Welcome to **gsplot** (General-Scientific Plot), a toolkit designed to elevate c
39
40
 
40
41
  [See more details](https://soichiroyamane.github.io/gsplot/stable/guides/demo/13_REPL.html)
41
42
 
42
- ![repl_tutorial](./docs/_static/tutorial/repl_tutorial_sp.gif)
43
+ ![repl_tutorial](./docs/_static/tutorial/repl_tutorial_45fps.gif)
43
44
 
44
45
  ## 🚀 Getting Started
45
46
 
@@ -1,7 +1,7 @@
1
1
  from .color.colormap import get_cmap
2
2
  from .config.config import (Config, config_dict, config_entry_option,
3
3
  config_load, save_metadata)
4
- from .data.load_file import load_file
4
+ from .data.load_file import load_file, load_file_fast
5
5
  from .figure.axes import axes
6
6
  from .figure.axes_inset import axes_inset, axes_inset_padding
7
7
  from .figure.figure_tools import get_figure_size
@@ -22,6 +22,7 @@ from .style.legend import (legend, legend_axes, legend_get_handlers,
22
22
  legend_handlers, legend_reverse)
23
23
  from .style.legend_colormap import legend_colormap
24
24
  from .style.ticks import ticks_off, ticks_on, ticks_on_axes
25
+ from .style.title import title, title_axes
25
26
  from .version import __commit__, __version__
26
27
 
27
28
  # ╭──────────────────────────────────────────────────────────╮
@@ -48,6 +49,7 @@ __all__ = [
48
49
  "get_cmap",
49
50
  # data/load_file.py
50
51
  "load_file",
52
+ "load_file_fast",
51
53
  # figure/axes.py
52
54
  "axes",
53
55
  # figure/axes_inset.py
@@ -70,8 +72,6 @@ __all__ = [
70
72
  "pwd_main",
71
73
  # plot/line.py
72
74
  "line",
73
- # plot/line_colormap.py
74
- "line_colormap",
75
75
  # plot/line_colormap_solid.py
76
76
  "line_colormap_solid",
77
77
  # plot/line_colormap_dashed.py
@@ -103,4 +103,7 @@ __all__ = [
103
103
  "ticks_off",
104
104
  "ticks_on",
105
105
  "ticks_on_axes",
106
+ # style/title.py
107
+ "title",
108
+ "title_axes",
106
109
  ]
@@ -6,7 +6,7 @@ from numpy.typing import NDArray
6
6
 
7
7
  from ..base.base import CreateClassParams, ParamsGetter, bind_passed_params
8
8
 
9
- __all__: list[str] = ["load_file"]
9
+ __all__: list[str] = ["load_file", "load_file_fast"]
10
10
 
11
11
 
12
12
  class LoadFile:
@@ -186,3 +186,146 @@ def load_file(
186
186
  **class_params["kwargs"],
187
187
  )
188
188
  return _load_file.load_data()
189
+
190
+
191
+ class LoadFileFast:
192
+ """
193
+ A utility class to load data from a file or iterable source using NumPy's `loadtxt`.
194
+
195
+ This class provides an interface for loading unstructured data from files or iterables
196
+ with options for handling delimiters and skipping rows.
197
+
198
+ Parameters
199
+ --------------------
200
+ f : str, os.PathLike, Iterable[str], or Iterable[bytes]
201
+ The file path, file-like object, or iterable source from which to load data.
202
+ delimiter : str or None, optional
203
+ The string used to separate values. If `None`, any whitespace is treated as a delimiter (default is ",").
204
+ skiprows : int, optional
205
+ The number of rows to skip at the beginning of the file (default is 0).
206
+ unpack : bool, optional
207
+ Whether to unpack columns into separate arrays (default is True).
208
+ **kwargs : Any
209
+ Additional keyword arguments to pass to NumPy's `loadtxt`.
210
+
211
+ Attributes
212
+ --------------------
213
+ f : str, os.PathLike, Iterable[str], or Iterable[bytes]
214
+ The file path, file-like object, or iterable source from which to load data.
215
+ delimiter : str or None
216
+ The string used to separate values.
217
+ skiprows : int
218
+ The number of rows to skip at the beginning of the file.
219
+ unpack : bool
220
+ Whether to unpack columns into separate arrays.
221
+ kwargs : Any
222
+ Additional arguments passed to `loadtxt`.
223
+
224
+ Methods
225
+ --------------------
226
+ load_data()
227
+ Loads the data using NumPy's `loadtxt` with the specified parameters.
228
+ """
229
+
230
+ def __init__(
231
+ self,
232
+ f: str | PathLike | Iterable[str] | Iterable[bytes],
233
+ delimiter: str | None = ",",
234
+ skiprows: int = 0,
235
+ unpack: bool = True,
236
+ **kwargs: Any,
237
+ ) -> None:
238
+ self.f: str | PathLike | Iterable[str] | Iterable[bytes] = f
239
+ self.delimiter: str | None = delimiter
240
+ self.skiprows: int = skiprows
241
+ self.unpack: bool = unpack
242
+ self.kwargs: Any = kwargs
243
+
244
+ def load_data(self) -> NDArray[Any]:
245
+ """
246
+ Loads the data using NumPy's `loadtxt` with the specified parameters.
247
+
248
+ Returns
249
+ --------------------
250
+ numpy.ndarray
251
+ The loaded data as a NumPy array.
252
+ """
253
+ data = np.loadtxt(
254
+ fname=self.f,
255
+ skiprows=self.skiprows,
256
+ delimiter=self.delimiter,
257
+ unpack=self.unpack,
258
+ **self.kwargs,
259
+ )
260
+ return data
261
+
262
+
263
+ @bind_passed_params()
264
+ def load_file_fast(
265
+ f: str | PathLike | Iterable[str] | Iterable[bytes],
266
+ delimiter: str | None = ",",
267
+ skiprows: int = 0,
268
+ unpack: bool = True,
269
+ **kwargs: Any,
270
+ ) -> NDArray[Any]:
271
+ """
272
+ Loads unstructured data from a file or iterable source using the specified parameters.
273
+
274
+ This function provides a flexible interface for loading data with NumPy's `loadtxt`.
275
+ It captures and processes the passed parameters, allowing for customized file loading
276
+ options, such as handling delimiters, skipping rows, and unpacking columns.
277
+
278
+ Parameters
279
+ --------------------
280
+ f : str, os.PathLike, Iterable[str], or Iterable[bytes]
281
+ The file path, file-like object, or iterable source from which to load data.
282
+ delimiter : str or None, optional
283
+ The string used to separate values. If `None`, any whitespace is treated as a delimiter (default is ",").
284
+ skiprows : int, optional
285
+ The number of rows to skip at the beginning of the file (default is 0).
286
+ unpack : bool, optional
287
+ Whether to unpack columns into separate arrays (default is True).
288
+ **kwargs : Any
289
+ Additional keyword arguments to pass to NumPy's `loadtxt`.
290
+
291
+ Notes
292
+ --------------------
293
+ This function utilizes the `ParamsGetter` to retrieve bound parameters and
294
+ the `CreateClassParams` class to handle the merging of default, configuration,
295
+ and passed parameters.
296
+
297
+ Returns
298
+ --------------------
299
+ numpy.ndarray
300
+ The loaded data as a NumPy array.
301
+
302
+ Raises
303
+ --------------------
304
+ ValueError
305
+ If the file cannot be loaded or parsed correctly.
306
+
307
+ Examples
308
+ --------------------
309
+ >>> import gsplot as gs
310
+ >>> data = gs.load_file_fast("data.csv", delimiter=",", skiprows=1, unpack=False)
311
+ >>> print(data)
312
+ array([[1.0, 2.0, 3.0],
313
+ [4.0, 5.0, 6.0],
314
+ [7.0, 8.0, 9.0]])
315
+
316
+ >>> data = gs.load_file_fast(["1,2,3", "4,5,6", "7,8,9"], delimiter=",", unpack=True)
317
+ >>> print(data)
318
+ [array([1.0, 4.0, 7.0]), array([2.0, 5.0, 8.0]), array([3.0, 6.0, 9.0])]
319
+ """
320
+
321
+ passed_params: dict[str, Any] = ParamsGetter("passed_params").get_bound_params()
322
+ class_params = CreateClassParams(passed_params).get_class_params()
323
+
324
+ _load_file_fast: LoadFileFast = LoadFileFast(
325
+ class_params["f"],
326
+ class_params["delimiter"],
327
+ class_params["skiprows"],
328
+ class_params["unpack"],
329
+ **class_params["kwargs"],
330
+ )
331
+ return _load_file_fast.load_data()
@@ -0,0 +1,145 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Callable, TypeVar
4
+
5
+ import matplotlib.pyplot as plt
6
+ import numpy as np
7
+ from matplotlib.axes import Axes
8
+ from matplotlib.transforms import Bbox
9
+ from numpy.typing import NDArray
10
+
11
+ from .figure_tools import FigureLayout
12
+
13
+ F = TypeVar("F", bound=Callable[..., Any])
14
+
15
+ __all__: list[str] = []
16
+
17
+
18
+ class AxisLayout:
19
+ """
20
+ A utility class for managing axis layout properties in a Matplotlib figure.
21
+
22
+ This class provides methods to retrieve an axis's position and size, both in
23
+ normalized figure coordinates and in physical units (inches). It integrates
24
+ with the `AxesResolver` and `FigureLayout` classes to ensure consistent layout
25
+ calculations.
26
+
27
+ Parameters
28
+ --------------------
29
+ ax : matplotlib.axes.Axes
30
+ The target `Axes` object for which to manage the
31
+
32
+ Attributes
33
+ --------------------
34
+ ax : matplotlib.axes.Axes
35
+ The target `Axes` object for which to manage the layout.
36
+ fig_size : numpy.ndarray
37
+ The size of the figure in inches as a NumPy array.
38
+
39
+ Methods
40
+ --------------------
41
+ get_axis_position()
42
+ Returns the position of the axis in normalized figure coordinates.
43
+ get_axis_size()
44
+ Returns the size of the axis in normalized figure coordinates.
45
+ get_axis_position_inches()
46
+ Returns the position of the axis in physical units (inches).
47
+ get_axis_size_inches()
48
+ Returns the size of the axis in physical units (inches).
49
+
50
+ Examples
51
+ --------------------
52
+ >>> fig, ax = plt.subplots()
53
+ >>> layout = AxisLayout(ax)
54
+ >>> position = layout.get_axis_position()
55
+ >>> size = layout.get_axis_size()
56
+ >>> position_inches = layout.get_axis_position_inches()
57
+ """
58
+
59
+ def __init__(self, ax: Axes) -> None:
60
+ self.ax: Axes = ax
61
+ self.fig_size: NDArray[Any] = FigureLayout().get_figure_size()
62
+
63
+ def get_axis_position(self) -> Bbox:
64
+ """
65
+ Retrieves the position of the axis in normalized figure coordinates.
66
+
67
+ Returns
68
+ --------------------
69
+ matplotlib.transforms.Bbox
70
+ The position of the axis as a bounding box in normalized coordinates.
71
+
72
+ Examples
73
+ --------------------
74
+ >>> layout = AxisLayout(axis_index=0)
75
+ >>> position = layout.get_axis_position()
76
+ >>> print(position)
77
+ Bbox(x0=0.1, y0=0.1, x1=0.9, y1=0.9)
78
+ """
79
+ axis_position = self.ax.get_position()
80
+ return axis_position
81
+
82
+ def get_axis_size(self) -> NDArray[Any]:
83
+ """
84
+ Retrieves the size of the axis in normalized figure coordinates.
85
+
86
+ Returns
87
+ --------------------
88
+ numpy.ndarray
89
+ The width and height of the axis as a NumPy array.
90
+
91
+ Examples
92
+ --------------------
93
+ >>> layout = AxisLayout(axis_index=0)
94
+ >>> size = layout.get_axis_size()
95
+ >>> print(size)
96
+ array([0.8, 0.8])
97
+ """
98
+ axis_position_size = np.array(self.get_axis_position().size)
99
+ return axis_position_size
100
+
101
+ def get_axis_position_inches(self) -> Bbox:
102
+ """
103
+ Retrieves the position of the axis in physical units (inches).
104
+
105
+ Returns
106
+ --------------------
107
+ matplotlib.transforms.Bbox
108
+ The position of the axis as a bounding box in inches.
109
+
110
+ Examples
111
+ --------------------
112
+ >>> layout = AxisLayout(axis_index=0)
113
+ >>> position_inches = layout.get_axis_position_inches()
114
+ >>> print(position_inches)
115
+ Bbox(x0=1.6, y0=1.6, x1=14.4, y1=14.4)
116
+ """
117
+
118
+ axis_position = self.get_axis_position()
119
+
120
+ axis_position_inches = Bbox.from_bounds(
121
+ axis_position.x0 * self.fig_size[0],
122
+ axis_position.y0 * self.fig_size[1],
123
+ axis_position.width * self.fig_size[0],
124
+ axis_position.height * self.fig_size[1],
125
+ )
126
+ return axis_position_inches
127
+
128
+ def get_axis_size_inches(self) -> NDArray[Any]:
129
+ """
130
+ Retrieves the size of the axis in physical units (inches).
131
+
132
+ Returns
133
+ --------------------
134
+ numpy.ndarray
135
+ The width and height of the axis in inches as a NumPy array.
136
+
137
+ Examples
138
+ --------------------
139
+ >>> layout = AxisLayout(axis_index=0)
140
+ >>> size_inches = layout.get_axis_size_inches()
141
+ >>> print(size_inches)
142
+ array([12.8, 12.8])
143
+ """
144
+ axis_position_size_inches = np.array(self.get_axis_position_inches().size)
145
+ return axis_position_size_inches
@@ -30,10 +30,6 @@ class InsetAxesBase:
30
30
  lab_lims : list[Any] | None, optional
31
31
  List specifying axis labels and limits for the inset axis.
32
32
  Expected format: [x_label, y_label, x_lim_min, x_lim_max, y_lim_min, y_lim_max].
33
- x_pad : int | float, default=2
34
- Horizontal padding for axis labels.
35
- y_pad : int | float, default=2
36
- Vertical padding for axis labels.
37
33
  minor_ticks : bool, default=True
38
34
  Whether to enable minor ticks on the inset axis.
39
35
  zoom : bool or tuple[tuple[int, int], tuple[int, int]], default=True
@@ -97,8 +93,6 @@ class InsetAxesBase:
97
93
  ax,
98
94
  axins,
99
95
  lab_lims: list[Any] | None = None,
100
- x_pad: int | float = 2,
101
- y_pad: int | float = 2,
102
96
  minor_ticks: bool = True,
103
97
  zoom: bool | tuple[tuple[int, int], tuple[int, int]] = True,
104
98
  zoom_color: ColorType = "black",
@@ -108,8 +102,6 @@ class InsetAxesBase:
108
102
  self.ax: Axes = ax
109
103
  self.axins: Axes = axins
110
104
  self.lab_lims: list[Any] | None = lab_lims
111
- self.x_pad: int | float = x_pad
112
- self.y_pad: int | float = y_pad
113
105
  self.minor_ticks: bool = minor_ticks
114
106
  self.zoom: bool | tuple[tuple[int, int], tuple[int, int]] = zoom
115
107
  self.zoom_color: ColorType = zoom_color
@@ -233,8 +225,6 @@ class InsetAxesBase:
233
225
 
234
226
  _label = Label(
235
227
  self.lab_lims,
236
- self.x_pad,
237
- self.y_pad,
238
228
  minor_ticks_axes=False,
239
229
  tight_layout=False,
240
230
  **self.kwargs,
@@ -246,7 +236,7 @@ class InsetAxesBase:
246
236
  raise ValueError("lab_lims has invalid shape")
247
237
 
248
238
  # Label the inset axes
249
- _label.configure_axis_labels(self.axins, x_lab, y_lab)
239
+ _label.configure_axis_labels(self.axins, x_lab, y_lab, **self.kwargs)
250
240
  # Set the axis limits
251
241
  _label.configure_axis_limits(self.axins, lims)
252
242
 
@@ -141,7 +141,7 @@ class Scatter:
141
141
  self.x,
142
142
  self.y,
143
143
  s=self.size,
144
- c=self.color,
144
+ color=self.color,
145
145
  alpha=self.alpha,
146
146
  **self.kwargs,
147
147
  )
@@ -187,7 +187,6 @@ def scatter(
187
187
  - Alias validation is performed using the `AliasValidator` class.
188
188
 
189
189
  - 's' (size)
190
- - 'c' (color)
191
190
 
192
191
  Returns
193
192
  --------------------
@@ -204,7 +203,6 @@ def scatter(
204
203
  """
205
204
  alias_map = {
206
205
  "s": "size",
207
- "c": "color",
208
206
  }
209
207
 
210
208
  passed_params: dict[str, Any] = ParamsGetter("passed_params").get_bound_params()
@@ -452,31 +452,39 @@ class Label:
452
452
  lab_lims : list[Any]
453
453
  A list specifying labels and limits for each axis in the figure. Each entry
454
454
  should be a tuple of the form `(x_label, y_label, x_limits, y_limits)`.
455
- x_pad : int, default=2
456
- Horizontal padding for tight layout.
457
- y_pad : int, default=2
458
- Vertical padding for tight layout.
455
+ xpad_label : int or float, default=5
456
+ Padding for the x-axis label.
457
+ ypad_label : int or float, default=5
458
+ Padding for the y-axis label.
459
459
  minor_ticks_axes : bool, default=True
460
460
  Whether to add minor ticks to all axes.
461
461
  tight_layout : bool, default=True
462
462
  Whether to apply `tight_layout` to the figure.
463
+ xpad_layout : int, default=2
464
+ Horizontal padding for tight layout.
465
+ ypad_layout : int, default=2
466
+ Vertical padding for tight layout.
463
467
  *args : Any
464
- Additional arguments for `plt.tight_layout`.
468
+ Additional arguments for `ax.set_xlabel` and `ax.set_ylabel.
465
469
  **kwargs : Any
466
- Additional keyword arguments for `plt.tight_layout`.
470
+ Additional keyword arguments for `ax.set_xlabel` and `ax.set_ylabel`.
467
471
 
468
472
  Attributes
469
473
  --------------------
470
474
  lab_lims : list[Any]
471
475
  The labels and limits configuration for the axes.
472
- x_pad : int
473
- Horizontal padding for tight layout.
474
- y_pad : int
475
- Vertical padding for tight layout.
476
+ xpad_label : int or float
477
+ Padding for the x-axis label.
478
+ ypad_label : int or float
479
+ Padding for the y-axis label.
476
480
  minor_ticks_axes : bool
477
481
  Whether minor ticks are enabled for axes.
478
482
  tight_layout : bool
479
483
  Whether `tight_layout` is applied.
484
+ xpad_layout : int
485
+ Horizontal padding for tight layout.
486
+ ypad_layout : int
487
+ Vertical padding for tight layout.
480
488
  _axes : list[Axes]
481
489
  List of axes in the current figure.
482
490
 
@@ -507,20 +515,22 @@ class Label:
507
515
  def __init__(
508
516
  self,
509
517
  lab_lims: list[Any],
510
- x_pad: int | float = 2,
511
- y_pad: int | float = 2,
518
+ xpad_label: int | float = 2,
519
+ ypad_label: int | float = 2,
512
520
  minor_ticks_axes: bool = True,
513
521
  tight_layout: bool = True,
514
- *args: Any,
522
+ xpad_layout: int | float = 2,
523
+ ypad_layout: int | float = 2,
515
524
  **kwargs: Any,
516
525
  ) -> None:
517
526
 
518
527
  self.lab_lims: list[Any] = lab_lims
519
- self.x_pad: int | float = x_pad
520
- self.y_pad: int | float = y_pad
528
+ self.xpad_label: int | float = xpad_label
529
+ self.ypad_label: int | float = ypad_label
521
530
  self.minor_ticks_axes: bool = minor_ticks_axes
522
531
  self.tight_layout: bool = tight_layout
523
- self.args: Any = args
532
+ self.xpad_layout: int | float = xpad_layout
533
+ self.ypad_layout: int | float = ypad_layout
524
534
  self.kwargs: Any = kwargs
525
535
 
526
536
  self._axes: list[Axes] = plt.gcf().axes
@@ -621,7 +631,15 @@ class Label:
621
631
  if self.minor_ticks_axes:
622
632
  MinorTicksAxes().set_minor_ticks_axes()
623
633
 
624
- def configure_axis_labels(self, ax: Axes, x_lab: str | None, y_lab: str | None):
634
+ def configure_axis_labels(
635
+ self,
636
+ ax: Axes,
637
+ x_lab: str | None,
638
+ y_lab: str | None,
639
+ xpad_label: int | float = 10,
640
+ ypad_label: int | float = 10,
641
+ **kwargs: Any,
642
+ ) -> None:
625
643
  """
626
644
  Configures the labels for a given axis.
627
645
 
@@ -633,20 +651,27 @@ class Label:
633
651
  The label for the x-axis. If `None`, the x-axis label is removed.
634
652
  y_lab : str, optional
635
653
  The label for the y-axis. If `None`, the y-axis label is removed.
654
+ xpad_label : int or float, default=5
655
+ Padding for the x-axis label.
656
+ ypad_label : int or float, default=5
657
+ Padding for the y-axis label.
658
+ **kwargs : Any
659
+ Additional keyword arguments for the labels.
636
660
 
637
661
  Returns
638
662
  --------------------
639
663
  None
640
664
  """
665
+
641
666
  if isinstance(x_lab, str):
642
- ax.set_xlabel(x_lab)
667
+ ax.set_xlabel(xlabel=x_lab, labelpad=xpad_label, **kwargs)
643
668
  elif x_lab is None:
644
669
  self.remove_xlabels(ax)
645
670
  else:
646
671
  raise ValueError("Invalid x-axis label. Must be a string or None.")
647
672
 
648
673
  if isinstance(y_lab, str):
649
- ax.set_ylabel(y_lab)
674
+ ax.set_ylabel(ylabel=y_lab, labelpad=ypad_label, **kwargs)
650
675
  elif y_lab is None:
651
676
  self.remove_ylabels(ax)
652
677
  else:
@@ -676,6 +701,7 @@ class Label:
676
701
  --------------------
677
702
  None
678
703
  """
704
+
679
705
  if lims:
680
706
  x_lims, y_lims = lims
681
707
 
@@ -714,18 +740,40 @@ class Label:
714
740
  )
715
741
 
716
742
  def set_labels(self):
743
+ """
744
+ Applies labels, limits, and scales to all axes based on the configuration.
745
+
746
+ Returns
747
+ --------------------
748
+ None
749
+
750
+ """
717
751
  final_axes_ranges = self._get_final_axes_ranges()
718
752
 
719
753
  for i, (x_lab, y_lab, *lims) in enumerate(self.lab_lims):
720
754
  ax = self._axes[i]
721
755
 
722
756
  # Configure axis labels
723
- self.configure_axis_labels(ax, x_lab, y_lab)
757
+ self.configure_axis_labels(
758
+ ax, x_lab, y_lab, self.xpad_label, self.ypad_label, **self.kwargs
759
+ )
724
760
 
725
761
  # Configure axis limits and scales
726
762
  self.configure_axis_limits(ax, lims, final_axes_ranges)
727
763
 
728
764
  def _calculate_padding_range(self, range: NDArray[Any]) -> NDArray[Any]:
765
+ """
766
+ Calculates the padding range for a given axis.
767
+
768
+ Parameters
769
+ --------------------
770
+ range : numpy.ndarray
771
+ The range of values for the axis.
772
+
773
+ Returns
774
+ --------------------
775
+ numpy.ndarray
776
+ """
729
777
 
730
778
  PADDING_FACTOR: float = 0.05
731
779
  span: float = range[1] - range[0]
@@ -736,11 +784,32 @@ class Label:
736
784
  def _get_wider_range(
737
785
  self, range1: NDArray[Any], range2: NDArray[Any]
738
786
  ) -> NDArray[Any]:
787
+ """
788
+ Calculates the wider range between two ranges.
789
+
790
+ Parameters
791
+ --------------------
792
+ range1 : numpy.ndarray
793
+ The first range of values.
794
+ range2 : numpy.ndarray
795
+ The second range of values.
796
+
797
+ Returns
798
+ --------------------
799
+ numpy.ndarray
800
+ """
739
801
 
740
802
  new_range = np.array([min(range1[0], range2[0]), max(range1[1], range2[1])])
741
803
  return new_range
742
804
 
743
805
  def _get_axes_ranges_current(self) -> list[list[NDArray[Any]]]:
806
+ """
807
+ Retrieves the current ranges for all axes.
808
+
809
+ Returns
810
+ --------------------
811
+ list[list[numpy.ndarray]]
812
+ """
744
813
 
745
814
  axes_ranges_current = []
746
815
  for ax in self._axes:
@@ -750,6 +819,13 @@ class Label:
750
819
  return axes_ranges_current
751
820
 
752
821
  def _get_final_axes_ranges(self) -> dict[Axes, list[NDArray[Any]]]:
822
+ """
823
+ Retrieves the final axes ranges for all axes.
824
+
825
+ Returns
826
+ --------------------
827
+ dict[matplotlib.axes.Axes, list[numpy.ndarray]]
828
+ """
753
829
  _axes_range_singleton = AxesRangeSingleton()
754
830
 
755
831
  axes_ranges_current = self._get_axes_ranges_current()
@@ -784,21 +860,28 @@ class Label:
784
860
 
785
861
  #! Xpad and Ypad will change the size of the axis
786
862
  def apply_tight_layout(self) -> None:
863
+ """
864
+ Applies `tight_layout` to the figure.
787
865
 
866
+ Returns
867
+ --------------------
868
+ None
869
+ """
788
870
  if self.tight_layout:
789
871
  # Ignore this warning when using inset_axes:
790
872
  # UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect
791
873
  with warnings.catch_warnings():
792
874
  warnings.simplefilter("ignore")
793
- try:
794
- plt.tight_layout(
795
- w_pad=self.x_pad, h_pad=self.y_pad, *self.args, **self.kwargs
796
- )
797
- except Exception:
798
- plt.tight_layout(w_pad=self.x_pad, h_pad=self.y_pad)
875
+ plt.tight_layout(w_pad=self.xpad_layout, h_pad=self.ypad_layout)
799
876
 
800
877
  def label(self) -> None:
878
+ """
879
+ Adds labels, limits, and layouts to the figure's axes.
801
880
 
881
+ Returns
882
+ --------------------
883
+ None
884
+ """
802
885
  self.add_minor_ticks_axes()
803
886
  self.set_labels()
804
887
  self.apply_tight_layout()
@@ -808,16 +891,17 @@ class Label:
808
891
  @track_order
809
892
  def label(
810
893
  lab_lims: list[Any],
811
- x_pad: int = 2,
812
- y_pad: int = 2,
894
+ xpad_label: int | float = 5,
895
+ ypad_label: int | float = 5,
813
896
  minor_ticks_axes: bool = True,
814
897
  tight_layout: bool = True,
898
+ xpad_layout: int = 2,
899
+ ypad_layout: int = 2,
815
900
  *args: Any,
816
901
  **kwargs: Any,
817
902
  ) -> None:
818
903
  """
819
904
  Configures labels, limits, ticks, and layouts for Matplotlib axes.
820
-
821
905
  This function is a wrapper for the `Label` class.
822
906
 
823
907
  Parameters
@@ -825,18 +909,22 @@ def label(
825
909
  lab_lims : list[Any]
826
910
  A list specifying labels and limits for each axis in the figure. Each entry
827
911
  should be a tuple of the form `(x_label, y_label, x_limits, y_limits)`.
828
- x_pad : int, default=2
829
- Horizontal padding for tight layout.
830
- y_pad : int, default=2
831
- Vertical padding for tight layout.
912
+ xpad_label : int or float, default=5
913
+ Padding for the x-axis label.
914
+ ypad_label : int or float, default=5
915
+ Padding for the y-axis label.
832
916
  minor_ticks_axes : bool, default=True
833
917
  Whether to add minor ticks to all axes.
834
918
  tight_layout : bool, default=True
835
919
  Whether to apply `tight_layout` to the figure.
920
+ xpad_layout : int, default=2
921
+ Horizontal padding for tight layout.
922
+ ypad_layout : int, default=2
923
+ Vertical padding for tight layout.
836
924
  *args : Any
837
- Additional arguments for `plt.tight_layout`.
925
+ Additional arguments for `ax.set_xlabel` and `ax.set_ylabel`.
838
926
  **kwargs : Any
839
- Additional keyword arguments for `plt.tight_layout`.
927
+ Additional keyword arguments for `ax.set_xlabel` and `ax.set_ylabel`.
840
928
 
841
929
  Notes
842
930
  --------------------
@@ -857,8 +945,8 @@ def label(
857
945
  >>> import gsplot as gs
858
946
  >>> gs.label(
859
947
  >>> lab_lims=[("X Label", "Y Label", [1, 10, "log"], [1, 20, 2])],
860
- >>> x_pad=5,
861
- >>> y_pad=5,
948
+ >>> xpad_layout=5,
949
+ >>> ypad_layout=5,
862
950
  >>> )
863
951
  """
864
952
 
@@ -867,11 +955,12 @@ def label(
867
955
 
868
956
  _label = Label(
869
957
  class_params["lab_lims"],
870
- class_params["x_pad"],
871
- class_params["y_pad"],
958
+ class_params["xpad_label"],
959
+ class_params["ypad_label"],
872
960
  class_params["minor_ticks_axes"],
873
961
  class_params["tight_layout"],
874
- *class_params["args"],
962
+ class_params["xpad_layout"],
963
+ class_params["ypad_layout"],
875
964
  **class_params["kwargs"],
876
965
  )
877
966
 
@@ -0,0 +1,122 @@
1
+ from typing import Any
2
+
3
+ import matplotlib.pyplot as plt
4
+ from matplotlib.axes import Axes
5
+ from matplotlib.text import Text
6
+
7
+ __all__ = ["title", "title_axes"]
8
+
9
+
10
+ class Title:
11
+ """
12
+ Set the title of the current figure.
13
+
14
+ Parameters
15
+ --------------------
16
+ title : str
17
+ **kwargs : Any
18
+
19
+ Attributes
20
+ --------------------
21
+ title : str
22
+ kwargs : Any
23
+
24
+ Methods
25
+ --------------------
26
+ set_title()
27
+ Set the title of the current figure
28
+ """
29
+
30
+ def __init__(self, title: str, **kwargs: Any) -> None:
31
+ self.title: str = title
32
+ self.kwargs: Any = kwargs
33
+
34
+ def set_title(self) -> Text:
35
+ """
36
+ Set the title of the current figure.
37
+
38
+ Returns
39
+ --------------------
40
+ Text
41
+ The title of the current figure.
42
+ """
43
+ return plt.gcf().suptitle(self.title, **self.kwargs)
44
+
45
+
46
+ def title(title: str, **kwargs: Any) -> Text:
47
+ """
48
+ Set the title of the current figure.
49
+
50
+ Parameters
51
+ --------------------
52
+ title : str
53
+ The title of the current figure.
54
+ **kwargs : Any
55
+ Additional keyword arguments to pass to the title.
56
+
57
+ Returns
58
+ --------------------
59
+ Text
60
+ The title of the current figure.
61
+ """
62
+ return Title(title=title, **kwargs).set_title()
63
+
64
+
65
+ class TitleAxes:
66
+ """
67
+ Set the title of the current figure.
68
+
69
+ Parameters
70
+ --------------------
71
+ ax : Axes
72
+ title : str
73
+ **kwargs : Any
74
+
75
+ Attributes
76
+ --------------------
77
+ ax : Axes
78
+ title : str
79
+ kwargs : Any
80
+
81
+ Methods
82
+ --------------------
83
+ set_title()
84
+ Set the title of the current figure
85
+ """
86
+
87
+ def __init__(self, ax: Axes, title: str, **kwargs: Any) -> None:
88
+ self.ax: Axes = ax
89
+ self.title: str = title
90
+ self.kwargs: Any = kwargs
91
+
92
+ def set_title(self) -> Text:
93
+ """
94
+ Set the title of the current figure.
95
+
96
+ Returns
97
+ --------------------
98
+ Text
99
+ The title of the current figure.
100
+ """
101
+ return self.ax.set_title(self.title, **self.kwargs)
102
+
103
+
104
+ def title_axes(ax: Axes, title: str, **kwargs: Any) -> Text:
105
+ """
106
+ Set the title of the current figure.
107
+
108
+ Parameters
109
+ --------------------
110
+ ax : Axes
111
+ The axes to set the title of.
112
+ title : str
113
+ The title of the current figure.
114
+ **kwargs : Any
115
+ Additional keyword arguments to pass to the title.
116
+
117
+ Returns
118
+ --------------------
119
+ Text
120
+ The title of the current figure.
121
+ """
122
+ return TitleAxes(ax=ax, title=title, **kwargs).set_title()
@@ -0,0 +1,2 @@
1
+ __version__ = '0.1.3'
2
+ __commit__ = '637c2d2e807a84c94b172b28e5c736bd885c3469'
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "gsplot"
3
3
 
4
- version = "0.1.1"
4
+ version = "0.1.3"
5
5
 
6
6
  description = "General-scientific plot based on matplotlib"
7
7
  authors = [
@@ -1,288 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Any, Callable, TypeVar
4
-
5
- import matplotlib.pyplot as plt
6
- import numpy as np
7
- from matplotlib.axes import Axes
8
- from matplotlib.transforms import Bbox
9
- from numpy.typing import NDArray
10
-
11
- from .figure_tools import FigureLayout
12
-
13
- F = TypeVar("F", bound=Callable[..., Any])
14
-
15
- __all__: list[str] = []
16
-
17
-
18
- # class AxesResolver:
19
- # """
20
- # Resolves an axis target to a Matplotlib `Axes` object or its index.
21
- #
22
- # This class provides a mechanism to convert an axis target, which can be either
23
- # an integer (index of the axis) or an `Axes` object, into a consistent representation
24
- # including the corresponding `Axes` object and its index within the current figure.
25
- #
26
- # Parameters
27
- # --------------------
28
- # axis_target : int or matplotlib.axes.Axes
29
- # The target axis to resolve. Can be an integer representing the index of the
30
- # axis in the current figure or a specific `Axes` object.
31
- #
32
- # Attributes
33
- # --------------------
34
- # axis_target : int or matplotlib.axes.Axes
35
- # The input target axis (as provided by the user).
36
- # _axis_index : int or None
37
- # The resolved index of the target axis in the current figure.
38
- # _axis : matplotlib.axes.Axes or None
39
- # The resolved `Axes` object corresponding to the target.
40
- #
41
- # Methods
42
- # --------------------
43
- # _resolve_type()
44
- # Resolves the type of the axis target and retrieves the corresponding
45
- # `Axes` object and its index.
46
- # axis_index
47
- # Returns the resolved index of the axis.
48
- # axis
49
- # Returns the resolved `Axes` object.
50
- #
51
- # Raises
52
- # --------------------
53
- # IndexError
54
- # If the provided axis index is out of range for the current figure.
55
- # ValueError
56
- # If the axis target is neither an integer nor an `Axes` object.
57
- #
58
- # Examples
59
- # --------------------
60
- # >>> import matplotlib.pyplot as plt
61
- # >>> fig, axs = plt.subplots(2, 2)
62
- # >>> resolver = AxesResolver(1) # Resolves the second axis (index 1)
63
- # >>> print(resolver.axis)
64
- # AxesSubplot(0.5,0.5;0.352273x0.352273)
65
- #
66
- # >>> resolver = AxesResolver(axs[0, 0]) # Resolves an Axes object directly
67
- # >>> print(resolver.axis_index)
68
- # 0
69
- # """
70
- #
71
- # def __init__(self, axis_target: int | Axes) -> None:
72
- # self.axis_target: int | Axes = axis_target
73
- #
74
- # self._axis_index: int | None = None
75
- # self._axis: Axes | None = None
76
- #
77
- # self._resolve_type()
78
- #
79
- # def _resolve_type(self) -> None:
80
- # """
81
- # Resolves the type of the axis target and retrieves the corresponding
82
- # `Axes` object and its index.
83
- #
84
- # Raises
85
- # --------------------
86
- # IndexError
87
- # If the provided axis index is out of range for the current figure.
88
- # ValueError
89
- # If the axis target is neither an integer nor an `Axes` object.
90
- # """
91
- #
92
- # def ordinal_suffix(n: int) -> str:
93
- # if 11 <= n % 100 <= 13:
94
- # suffix = "th"
95
- # else:
96
- # suffix = {1: "st", 2: "nd", 3: "rd"}.get(n % 10, "th")
97
- # return f"{n}{suffix}"
98
- #
99
- # if isinstance(self.axis_target, int):
100
- # self._axis_index = self.axis_target
101
- # axes = plt.gcf().axes
102
- # try:
103
- # self._axis = axes[self._axis_index]
104
- # except IndexError:
105
- # error_message = f"Axes out of range: {self._axis_index} => Number of axes: {len(axes)}, but requested {ordinal_suffix(self._axis_index + 1)} axis."
106
- # raise IndexError(error_message)
107
- # elif isinstance(self.axis_target, Axes):
108
- # self._axis = self.axis_target
109
- # if self.axis_target in plt.gcf().axes:
110
- # self._axis_index = plt.gcf().axes.index(self._axis)
111
- # else:
112
- # # Add the axis to the current figure if it is not present
113
- # plt.gcf().add_axes(self._axis)
114
- # self._axis_index = len(plt.gcf().axes) - 1
115
- # else:
116
- # raise ValueError(
117
- # "Invalid axis target. Please provide an integer or Axes object."
118
- # )
119
- #
120
- # @property
121
- # def axis_index(self) -> int:
122
- # """
123
- # Returns the resolved index of the target axis.
124
- #
125
- # Returns
126
- # --------------------
127
- # int
128
- # The index of the resolved axis.
129
- #
130
- # Raises
131
- # --------------------
132
- # ValueError
133
- # If the axis index is not resolved.
134
- # """
135
- # if isinstance(self._axis_index, int):
136
- # return self._axis_index
137
- # else:
138
- # raise ValueError("Axis index not resolved. Please check the AxisResolver")
139
- #
140
- # @property
141
- # def axis(self) -> Axes:
142
- # """
143
- # Returns the resolved `Axes` object.
144
- #
145
- # Returns
146
- # --------------------
147
- # matplotlib.axes.Axes
148
- # The resolved `Axes` object.
149
- #
150
- # Raises
151
- # --------------------
152
- # ValueError
153
- # If the axis is not resolved.
154
- # """
155
- # if isinstance(self._axis, Axes):
156
- # return self._axis
157
- # else:
158
- # raise ValueError("Axis not resolced. Please check the AxisResolver")
159
-
160
-
161
- class AxisLayout:
162
- """
163
- A utility class for managing axis layout properties in a Matplotlib figure.
164
-
165
- This class provides methods to retrieve an axis's position and size, both in
166
- normalized figure coordinates and in physical units (inches). It integrates
167
- with the `AxesResolver` and `FigureLayout` classes to ensure consistent layout
168
- calculations.
169
-
170
- Parameters
171
- --------------------
172
- ax : matplotlib.axes.Axes
173
- The target `Axes` object for which to manage the
174
-
175
- Attributes
176
- --------------------
177
- ax : matplotlib.axes.Axes
178
- The target `Axes` object for which to manage the layout.
179
- fig_size : numpy.ndarray
180
- The size of the figure in inches as a NumPy array.
181
-
182
- Methods
183
- --------------------
184
- get_axis_position()
185
- Returns the position of the axis in normalized figure coordinates.
186
- get_axis_size()
187
- Returns the size of the axis in normalized figure coordinates.
188
- get_axis_position_inches()
189
- Returns the position of the axis in physical units (inches).
190
- get_axis_size_inches()
191
- Returns the size of the axis in physical units (inches).
192
-
193
- Examples
194
- --------------------
195
- >>> fig, ax = plt.subplots()
196
- >>> layout = AxisLayout(ax)
197
- >>> position = layout.get_axis_position()
198
- >>> size = layout.get_axis_size()
199
- >>> position_inches = layout.get_axis_position_inches()
200
- """
201
-
202
- def __init__(self, ax: Axes) -> None:
203
- self.ax: Axes = ax
204
- self.fig_size: NDArray[Any] = FigureLayout().get_figure_size()
205
-
206
- def get_axis_position(self) -> Bbox:
207
- """
208
- Retrieves the position of the axis in normalized figure coordinates.
209
-
210
- Returns
211
- --------------------
212
- matplotlib.transforms.Bbox
213
- The position of the axis as a bounding box in normalized coordinates.
214
-
215
- Examples
216
- --------------------
217
- >>> layout = AxisLayout(axis_index=0)
218
- >>> position = layout.get_axis_position()
219
- >>> print(position)
220
- Bbox(x0=0.1, y0=0.1, x1=0.9, y1=0.9)
221
- """
222
- axis_position = self.ax.get_position()
223
- return axis_position
224
-
225
- def get_axis_size(self) -> NDArray[Any]:
226
- """
227
- Retrieves the size of the axis in normalized figure coordinates.
228
-
229
- Returns
230
- --------------------
231
- numpy.ndarray
232
- The width and height of the axis as a NumPy array.
233
-
234
- Examples
235
- --------------------
236
- >>> layout = AxisLayout(axis_index=0)
237
- >>> size = layout.get_axis_size()
238
- >>> print(size)
239
- array([0.8, 0.8])
240
- """
241
- axis_position_size = np.array(self.get_axis_position().size)
242
- return axis_position_size
243
-
244
- def get_axis_position_inches(self) -> Bbox:
245
- """
246
- Retrieves the position of the axis in physical units (inches).
247
-
248
- Returns
249
- --------------------
250
- matplotlib.transforms.Bbox
251
- The position of the axis as a bounding box in inches.
252
-
253
- Examples
254
- --------------------
255
- >>> layout = AxisLayout(axis_index=0)
256
- >>> position_inches = layout.get_axis_position_inches()
257
- >>> print(position_inches)
258
- Bbox(x0=1.6, y0=1.6, x1=14.4, y1=14.4)
259
- """
260
-
261
- axis_position = self.get_axis_position()
262
-
263
- axis_position_inches = Bbox.from_bounds(
264
- axis_position.x0 * self.fig_size[0],
265
- axis_position.y0 * self.fig_size[1],
266
- axis_position.width * self.fig_size[0],
267
- axis_position.height * self.fig_size[1],
268
- )
269
- return axis_position_inches
270
-
271
- def get_axis_size_inches(self) -> NDArray[Any]:
272
- """
273
- Retrieves the size of the axis in physical units (inches).
274
-
275
- Returns
276
- --------------------
277
- numpy.ndarray
278
- The width and height of the axis in inches as a NumPy array.
279
-
280
- Examples
281
- --------------------
282
- >>> layout = AxisLayout(axis_index=0)
283
- >>> size_inches = layout.get_axis_size_inches()
284
- >>> print(size_inches)
285
- array([12.8, 12.8])
286
- """
287
- axis_position_size_inches = np.array(self.get_axis_position_inches().size)
288
- return axis_position_size_inches
@@ -1,2 +0,0 @@
1
- __version__ = '0.1.1'
2
- __commit__ = '1edf3b25e5a53fef29c008d68dd3c0035ea93fe6'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes