gsplot 0.1.1__tar.gz → 0.1.2__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 (34) hide show
  1. {gsplot-0.1.1 → gsplot-0.1.2}/PKG-INFO +4 -3
  2. {gsplot-0.1.1 → gsplot-0.1.2}/README.md +3 -2
  3. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/figure/axes_inset.py +1 -11
  4. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/style/label.py +129 -39
  5. gsplot-0.1.2/gsplot/version.py +2 -0
  6. {gsplot-0.1.1 → gsplot-0.1.2}/pyproject.toml +1 -1
  7. gsplot-0.1.1/gsplot/version.py +0 -2
  8. {gsplot-0.1.1 → gsplot-0.1.2}/LICENSE +0 -0
  9. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/__init__.py +0 -0
  10. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/base/base.py +0 -0
  11. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/base/base_alias_validator.py +0 -0
  12. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/color/colormap.py +0 -0
  13. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/config/config.py +0 -0
  14. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/data/load_file.py +0 -0
  15. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/figure/axes.py +0 -0
  16. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/figure/axes_base.py +0 -0
  17. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/figure/axes_range_base.py +0 -0
  18. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/figure/figure_tools.py +0 -0
  19. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/figure/show.py +0 -0
  20. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/figure/store.py +0 -0
  21. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/hello_world/hello_world.py +0 -0
  22. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/logger.py +0 -0
  23. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/path/path.py +0 -0
  24. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/plot/line.py +0 -0
  25. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/plot/line_base.py +0 -0
  26. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/plot/line_colormap_base.py +0 -0
  27. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/plot/line_colormap_dashed.py +0 -0
  28. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/plot/line_colormap_solid.py +0 -0
  29. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/plot/scatter.py +0 -0
  30. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/plot/scatter_colormap.py +0 -0
  31. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/style/graph.py +0 -0
  32. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/style/legend.py +0 -0
  33. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/style/legend_colormap.py +0 -0
  34. {gsplot-0.1.1 → gsplot-0.1.2}/gsplot/style/ticks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gsplot
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
 
@@ -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
 
@@ -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,10 +891,12 @@ 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:
@@ -825,18 +910,22 @@ def label(
825
910
  lab_lims : list[Any]
826
911
  A list specifying labels and limits for each axis in the figure. Each entry
827
912
  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.
913
+ xpad_label : int or float, default=5
914
+ Padding for the x-axis label.
915
+ ypad_label : int or float, default=5
916
+ Padding for the y-axis label.
832
917
  minor_ticks_axes : bool, default=True
833
918
  Whether to add minor ticks to all axes.
834
919
  tight_layout : bool, default=True
835
920
  Whether to apply `tight_layout` to the figure.
921
+ xpad_layout : int, default=2
922
+ Horizontal padding for tight layout.
923
+ ypad_layout : int, default=2
924
+ Vertical padding for tight layout.
836
925
  *args : Any
837
- Additional arguments for `plt.tight_layout`.
926
+ Additional arguments for `ax.set_xlabel` and `ax.set_ylabel.
838
927
  **kwargs : Any
839
- Additional keyword arguments for `plt.tight_layout`.
928
+ Additional keyword arguments for `ax.set_xlabel` and `ax.set_ylabel`.
840
929
 
841
930
  Notes
842
931
  --------------------
@@ -857,8 +946,8 @@ def label(
857
946
  >>> import gsplot as gs
858
947
  >>> gs.label(
859
948
  >>> lab_lims=[("X Label", "Y Label", [1, 10, "log"], [1, 20, 2])],
860
- >>> x_pad=5,
861
- >>> y_pad=5,
949
+ >>> xpad_layout=5,
950
+ >>> ypad_layout=5,
862
951
  >>> )
863
952
  """
864
953
 
@@ -867,11 +956,12 @@ def label(
867
956
 
868
957
  _label = Label(
869
958
  class_params["lab_lims"],
870
- class_params["x_pad"],
871
- class_params["y_pad"],
959
+ class_params["xpad_label"],
960
+ class_params["ypad_label"],
872
961
  class_params["minor_ticks_axes"],
873
962
  class_params["tight_layout"],
874
- *class_params["args"],
963
+ class_params["xpad_layout"],
964
+ class_params["ypad_layout"],
875
965
  **class_params["kwargs"],
876
966
  )
877
967
 
@@ -0,0 +1,2 @@
1
+ __version__ = '0.1.2'
2
+ __commit__ = '828d28fda62f1f1935e76112444e53617990c7cc'
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "gsplot"
3
3
 
4
- version = "0.1.1"
4
+ version = "0.1.2"
5
5
 
6
6
  description = "General-scientific plot based on matplotlib"
7
7
  authors = [
@@ -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
File without changes
File without changes
File without changes