tikzplot42 0.6.4__tar.gz → 0.6.5__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 (64) hide show
  1. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/PKG-INFO +2 -1
  2. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/pyproject.toml +2 -2
  3. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/axes.py +16 -13
  4. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/axes.pyi +9 -3
  5. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/colorbar.py +4 -4
  6. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/colors.py +4 -4
  7. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/figure.py +4 -0
  8. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/figure.pyi +29 -7
  9. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/plots.py +11 -2
  10. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/plots.pyi +31 -3
  11. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot42.egg-info/PKG-INFO +2 -1
  12. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot42.egg-info/requires.txt +1 -0
  13. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/LICENSE +0 -0
  14. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/README.md +0 -0
  15. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/setup.cfg +0 -0
  16. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/__init__.py +0 -0
  17. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/__init__.pyi +0 -0
  18. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/arrows.py +0 -0
  19. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/axes3d.py +0 -0
  20. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/axes3d.pyi +0 -0
  21. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/border_finder.py +0 -0
  22. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/colorbar.pyi +0 -0
  23. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/config.py +0 -0
  24. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/config.pyi +0 -0
  25. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/elements.py +0 -0
  26. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/elements.pyi +0 -0
  27. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/latex_special.py +0 -0
  28. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/pie.py +0 -0
  29. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/py.typed +0 -0
  30. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/state.py +0 -0
  31. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/styles.py +0 -0
  32. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/styles.pyi +0 -0
  33. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot/texts.py +0 -0
  34. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot42.egg-info/SOURCES.txt +0 -0
  35. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot42.egg-info/dependency_links.txt +0 -0
  36. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/src/tikzplot42.egg-info/top_level.txt +0 -0
  37. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test1.py +0 -0
  38. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test10.py +0 -0
  39. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test11.py +0 -0
  40. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test12.py +0 -0
  41. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test13.py +0 -0
  42. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test14.py +0 -0
  43. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test15.py +0 -0
  44. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test16.py +0 -0
  45. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test17.py +0 -0
  46. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test18.py +0 -0
  47. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test19.py +0 -0
  48. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test2.py +0 -0
  49. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test20.py +0 -0
  50. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test21.py +0 -0
  51. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test22.py +0 -0
  52. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test23.py +0 -0
  53. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test24.py +0 -0
  54. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test25.py +0 -0
  55. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test26.py +0 -0
  56. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test27.py +0 -0
  57. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test28.py +0 -0
  58. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test3.py +0 -0
  59. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test4.py +0 -0
  60. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test5.py +0 -0
  61. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test6.py +0 -0
  62. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test7.py +0 -0
  63. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test8.py +0 -0
  64. {tikzplot42-0.6.4 → tikzplot42-0.6.5}/tests/test9.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tikzplot42
3
- Version: 0.6.4
3
+ Version: 0.6.5
4
4
  Summary: TikzPlot to make TikZ/PGFPlots plots with matplotlib.pyplot-like syntax.
5
5
  Author-email: Zan Ambrozic <zan.ambrozic7@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -696,6 +696,7 @@ License-File: LICENSE
696
696
  Requires-Dist: numpy
697
697
  Requires-Dist: matplotlib
698
698
  Requires-Dist: scipy
699
+ Requires-Dist: scikit-image
699
700
  Dynamic: license-file
700
701
 
701
702
  # TikzPlot
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tikzplot42"
7
- version = "0.6.4"
7
+ version = "0.6.5"
8
8
  description = "TikzPlot to make TikZ/PGFPlots plots with matplotlib.pyplot-like syntax."
9
9
  authors = [
10
10
  { name = "Zan Ambrozic", email = "zan.ambrozic7@gmail.com" }
@@ -23,7 +23,7 @@ classifiers = [
23
23
  "Programming Language :: Python :: 3.14",
24
24
  "Topic :: Scientific/Engineering :: Visualization",
25
25
  ]
26
- dependencies = ["numpy", "matplotlib", "scipy"]
26
+ dependencies = ["numpy", "matplotlib", "scipy", "scikit-image"]
27
27
 
28
28
  [project.urls]
29
29
  Homepage = "https://github.com/ZanAmb/TikzPlot"
@@ -1,5 +1,3 @@
1
- from math import isqrt
2
- from turtle import pos
3
1
  from typing import Any, Iterable, Tuple
4
2
  import copy
5
3
 
@@ -644,9 +642,9 @@ class BaseAxes:
644
642
  if "colors" in kwargs:
645
643
  colors = kwargs.pop("colors")
646
644
  if isinstance(colors, list):
647
- trgts = None if _np.isclose(_np.min(_np.diff(levels)), _np.max(_np.diff(levels))) else levels
645
+ #trgts = None if _np.isclose(_np.min(_np.diff(levels)), _np.max(_np.diff(levels))) else levels
648
646
  kwargs["cmap"] = colors
649
- cb = Colorbar(cmap=colors, lower=vmin, upper=vmax, targets=trgts)
647
+ cb = Colorbar(cmap=colors, lower=vmin, upper=vmax, targets=levels)
650
648
  else:
651
649
  cb = None
652
650
  kwargs["color"] = colors
@@ -1800,11 +1798,13 @@ class BaseAxes:
1800
1798
  if "base" in kwargs:
1801
1799
  self._axis_options["log basis y"] = kwargs["base"]
1802
1800
 
1803
- def set_yticks(self, *ticks, labels=None, **kwargs):
1801
+ def set_yticks(self, *ticks, labels=None, scaled=None, **kwargs):
1804
1802
  pass_to_labels = {"rotation", "va", "verticalalignment", "ha", "horizontalalignment"}
1805
1803
  kws = {"color", "c", "fontsize"} | pass_to_labels
1806
1804
  kwargs = self._check_kwargs("set_yticks", kws, **kwargs)
1807
1805
  st = {}
1806
+ if scaled is not None:
1807
+ self._axis_options["scaled y ticks"] = "true" if scaled else "false"
1808
1808
  if "color" in kwargs or "c" in kwargs:
1809
1809
  c = kwargs.get("color", kwargs.get("c", None))
1810
1810
  st["text"] = self._match_color(c)
@@ -1818,14 +1818,14 @@ class BaseAxes:
1818
1818
  if ticks:
1819
1819
  if len(ticks) == 2:
1820
1820
  ticks, labels = ticks
1821
- elif len(ticks) == 1 and isinstance(ticks[0], (list, tuple)):
1822
- ticks = ticks[0]
1821
+ elif len(ticks) == 1 and isinstance(ticks[0], Iterable):
1822
+ ticks = list(ticks[0])
1823
1823
  else: raise Warning("Too many positional arguments for set_xticks. Expected 1 or 2.")
1824
1824
  if list(ticks) != []:
1825
1825
  s_ticks = map(str, ticks)
1826
1826
  self._axis_options["ytick"]=f"{{{','.join(s_ticks)}}}"
1827
1827
  if labels is not None and len(labels)==len(ticks):
1828
- self._axis_options["yticklabels"]=f"{{{tex_text(','.join (labels))}}}"
1828
+ self._axis_options["yticklabels"]=f"{{{tex_text(','.join(labels))}}}"
1829
1829
  elif labels is not None and len(labels) == 0:
1830
1830
  self._axis_options["yticklabels"]=r"{}"
1831
1831
  self._yticks = False
@@ -1877,6 +1877,7 @@ class BaseAxes:
1877
1877
  self._axis_options["yticklabels"]=f"{{{tex_text(','.join(labels[0]))}}}"
1878
1878
  else:
1879
1879
  self._axis_options["yticklabels"]=r"{}"
1880
+ self._axis_options["scaled y ticks"]="false"
1880
1881
  self._yticks = False
1881
1882
 
1882
1883
  def set_xlabel(self, label, **kwargs):
@@ -2021,12 +2022,14 @@ class BaseAxes:
2021
2022
  if "base" in kwargs:
2022
2023
  self._axis_options["log basis x"] = kwargs["base"]
2023
2024
 
2024
- def set_xticks(self, *ticks, labels=None, **kwargs):
2025
+ def set_xticks(self, *ticks, labels=None, scaled=None, **kwargs):
2025
2026
  if isinstance(self, Secondary):
2026
2027
  return self._primary.set_xticks(*ticks, labels=labels, **kwargs)
2027
2028
  pass_to_labels = {"rotation", "ha", "horizontalalignment", "va", "verticalalignment"}
2028
2029
  kws = {"color", "c", "fontsize"} | pass_to_labels
2029
2030
  kwargs = self._check_kwargs("set_xticks", kws, **kwargs)
2031
+ if scaled is not None:
2032
+ self._axis_options["scaled x ticks"] = "true" if scaled else "false"
2030
2033
  st = {}
2031
2034
  if "color" in kwargs or "c" in kwargs:
2032
2035
  c = kwargs.get("color", kwargs.get("c", None))
@@ -2041,8 +2044,8 @@ class BaseAxes:
2041
2044
  if ticks:
2042
2045
  if len(ticks) == 2:
2043
2046
  ticks, labels = ticks
2044
- elif len(ticks) == 1 and isinstance(ticks[0], (list, tuple)):
2045
- ticks = ticks[0]
2047
+ elif len(ticks) == 1 and isinstance(ticks[0], Iterable):
2048
+ ticks = list(ticks[0])
2046
2049
  else: raise Warning("Too many positional arguments for set_xticks. Expected 1 or 2.")
2047
2050
  if list(ticks) != []:
2048
2051
  s_ticks = map(str, ticks)
@@ -2102,9 +2105,9 @@ class BaseAxes:
2102
2105
  self._axis_options["xticklabels"]=f"{{{tex_text(','.join(labels[0]))}}}"
2103
2106
  else:
2104
2107
  self._axis_options["xticklabels"]=r"{}"
2108
+ self._axis_options["scaled x ticks"]="false"
2105
2109
  self._xticks = False
2106
2110
 
2107
-
2108
2111
  def tick_params(self, axis="both", **kwargs):
2109
2112
  kws = {"color", "c", "labelsize", "labelcolor", "colors", "direction", "top", "bottom", "left", "right", "labelbottom", "labelleft"}
2110
2113
  kwargs = self._check_kwargs("tick_params", kws, **kwargs)
@@ -2174,7 +2177,7 @@ class BaseAxes:
2174
2177
  elif self._axis_options["ytick pos"] == "none":
2175
2178
  self._update_axis_options("ytick style", {"draw": self._axis_options.pop("ytick pos")})
2176
2179
 
2177
- _LEGEND_LOC_MAP = ["best", "upper right", "upper left", "lower_left", "lower right", "right", "center left", "center right", "lower center", "upper center", "center"]
2180
+ _LEGEND_LOC_MAP = ["best", "upper right", "upper left", "lower left", "lower right", "right", "center left", "center right", "lower center", "upper center", "center"]
2178
2181
  _ANCHOR_MAP = {"top": "north", "bottom": "south", "upper": "north", "lower": "south", "left": "west", "right": "east", "center": "center"}
2179
2182
  _FONT_SIZE_MAP = {"xx-small": "tiny", "x-small": "scriptsize", "small": "footnotesize", "medium": "small", "large": "normalsize", "x-large": "large", "xx-large": "Large"}
2180
2183
 
@@ -1896,7 +1896,7 @@ class BaseAxes:
1896
1896
  Set y-axis scale (to log).
1897
1897
  """
1898
1898
  ...
1899
- def set_yticks(self, *ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., fontsize: Optional[FontSize] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
1899
+ def set_yticks(self, *ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., scaled: Optional[bool] = ..., fontsize: Optional[FontSize] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
1900
1900
  """
1901
1901
  Set y-axis ticks and their labels.
1902
1902
 
@@ -1908,6 +1908,9 @@ class BaseAxes:
1908
1908
  labels: sequence of str, optional
1909
1909
  Tick labels, if not provided, the tick positions are used as labels
1910
1910
 
1911
+ scaled: bool, optional
1912
+ If False, automatic tick labels will be written without scale factor (e.g., 1e-3). If unchanged, LateX default is used.
1913
+
1911
1914
  fontsize: FontSize or int, optional
1912
1915
  Font size of tick labels
1913
1916
 
@@ -2029,7 +2032,7 @@ class BaseAxes:
2029
2032
  Set x-axis scale (to log).
2030
2033
  """
2031
2034
  ...
2032
- def set_xticks(self, *ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., fontsize: Optional[FontSize] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
2035
+ def set_xticks(self, *ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., scaled: Optional[bool] = ..., fontsize: Optional[FontSize] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
2033
2036
  """
2034
2037
  Set x-axis ticks and their labels.
2035
2038
 
@@ -2041,6 +2044,9 @@ class BaseAxes:
2041
2044
  labels: sequence of str, optional
2042
2045
  Labels for the ticks. If not provided, the tick positions will be used as labels.
2043
2046
 
2047
+ scaled: bool, optional
2048
+ If False, automatic tick labels will be written without scale factor (e.g., 1e-3). If unchanged, LaTeX default is used.
2049
+
2044
2050
  fontsize: FontSize, optional
2045
2051
  Font size of the tick labels.
2046
2052
 
@@ -2116,7 +2122,7 @@ class BaseAxes:
2116
2122
  """
2117
2123
  ...
2118
2124
 
2119
- def legend(self, *args: Any, loc: Optional[Union[int,str,Tuple[float,float]]] = ..., facecolor: Optional[ColorLike] = ..., edgecolor: Optional[ColorLike] = ..., labelcolor: Optional[ColorLike] = ..., frameon: Optional[bool] = ..., anchor: Optional[Literal["north", "south", "east", "west", "center", "north west", "north east", "south west", "south east"]] = ..., fontsize: Optional[Literal["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"] | int] = ..., ncols: Optional[int] = 1, reverse: Optional[bool] = False) -> None:
2125
+ def legend(self, *args: Any, loc: Optional[Union[int,Literal["upper right", "upper left", "lower left", "lower right", "right", "center left", "center right", "lower center", "upper center", "center"],Tuple[float,float]]] = ..., facecolor: Optional[ColorLike] = ..., edgecolor: Optional[ColorLike] = ..., labelcolor: Optional[ColorLike] = ..., frameon: Optional[bool] = ..., anchor: Optional[Literal["north", "south", "east", "west", "center", "north west", "north east", "south west", "south east"]] = ..., fontsize: Optional[Literal["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"] | int] = ..., ncols: Optional[int] = 1, reverse: Optional[bool] = False) -> None:
2120
2126
  """
2121
2127
  Show legend for the selected axis. Despite arguments requires at least one plotted element on the axis (not necesarily with label) to show up (LaTeX does not allow legend on empty axis).
2122
2128
 
@@ -45,7 +45,7 @@ class _Colorbar:
45
45
  if "cmap" in kwargs:
46
46
  self._cmap = kwargs["cmap"]
47
47
  if isinstance(self._cmap, list):
48
- self._cmap = [tuple(i / 255 for i in _tex_color_rgb(c)[0]) for c in self._cmap]
48
+ self._cmap = [tuple(i for i in _tex_color_rgb(c)[0]) for c in self._cmap]
49
49
  if "lower" in kwargs:
50
50
  self._lower = kwargs["lower"]
51
51
  if "upper" in kwargs:
@@ -245,16 +245,16 @@ class _Colorbar:
245
245
  if self._targets is not None:
246
246
  for i in range(len(self._targets)):
247
247
  r,g,b = colors[i]
248
- output.append(f" rgb({self._targets[i]})=({r:.4f}, {g:.4f}, {b:.4f})")
248
+ output.append(f"rgb({self._targets[i]})=({r:.4f}, {g:.4f}, {b:.4f})")
249
249
  else:
250
250
  for r, g, b in colors:
251
- output.append(f" rgb=({r:.4f}, {g:.4f}, {b:.4f})")
251
+ output.append(f"rgb=({r:.4f}, {g:.4f}, {b:.4f})")
252
252
  else:
253
253
  lims = _np.linspace(0,1, self._divs+1, endpoint=True)
254
254
  lims[-1] += 0.001
255
255
  for i in range(self._divs):
256
256
  r,g,b = colors[i]
257
- output.append(f" rgb({lims[i]})=({r:.4f}, {g:.4f}, {b:.4f}) rgb({lims[i+1]-0.001})=({r:.4f}, {g:.4f}, {b:.4f})")
257
+ output.append(f"rgb({lims[i]})=({r:.4f}, {g:.4f}, {b:.4f}) rgb({lims[i+1]-0.001})=({r:.4f}, {g:.4f}, {b:.4f})")
258
258
  output.append("}")
259
259
  return "\n".join(output)
260
260
 
@@ -265,7 +265,7 @@ def _tex_to_rgb(color):
265
265
  else:
266
266
  components = color.split("!")
267
267
  if len(components) == 1:
268
- color = _TEX_COLOR_MAP.get(components[0], (0,0,0))
268
+ color = [q / 255 for q in _TEX_COLOR_MAP.get(components[0], (0,0,0))]
269
269
  else:
270
270
  base = components[0]
271
271
  if len(components) == 3:
@@ -275,9 +275,9 @@ def _tex_to_rgb(color):
275
275
  ratio = int(components[1]) / 100
276
276
  r1,g1,b1 = _TEX_COLOR_MAP.get(base, (0,0,0))
277
277
  r2,g2,b2 = _TEX_COLOR_MAP.get(second, (255,255,255))
278
- r = int(r1 * (1 - ratio) + r2 * ratio)
279
- g = int(g1 * (1 - ratio) + g2 * ratio)
280
- b = int(b1 * (1 - ratio) + b2 * ratio)
278
+ r = int(r1 * (1 - ratio) + r2 * ratio) / 255
279
+ g = int(g1 * (1 - ratio) + g2 * ratio) / 255
280
+ b = int(b1 * (1 - ratio) + b2 * ratio) / 255
281
281
  color = (r,g,b)
282
282
  return color
283
283
 
@@ -86,6 +86,10 @@ class Figure:
86
86
  axes = self._add_subplots(nrows, ncols, sharex, sharey, subplot_kw)
87
87
  if "figsize" in kwargs:
88
88
  self.set_size_inches(kwargs["figsize"])
89
+ if "width_ratios" in kwargs:
90
+ self._wratios = kwargs["width_ratios"]
91
+ if "height_ratios" in kwargs:
92
+ self._hratios = kwargs["height_ratios"]
89
93
  if nrows * ncols == 1:
90
94
  return axes[0]
91
95
  grid = []
@@ -82,7 +82,9 @@ class Figure:
82
82
  sharey: Optional[Any] = ...,
83
83
  subplot_kw: _SubplotKw3D,
84
84
  figsize: Optional[tuple[float, float]] = ...,
85
- ) -> tuple[Figure, Axes3]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
85
+ height_ratios: Optional[Sequence[float|int]]= ...,
86
+ width_ratios: Optional[Sequence[float|int]]= ...
87
+ ) -> Axes3: ... # type: ignore[overload-overlap, reportOverlappingOverload]
86
88
 
87
89
  @overload
88
90
  def subplots( # type: ignore[overload-overlap, reportOverlappingOverload]
@@ -94,6 +96,8 @@ class Figure:
94
96
  sharey: Optional[Any] = ...,
95
97
  subplot_kw: _SubplotKw3D,
96
98
  figsize: Optional[tuple[float, float]] = ...,
99
+ height_ratios: Optional[Sequence[float|int]]= ...,
100
+ width_ratios: Optional[Sequence[float|int]]= ...
97
101
  ) -> tuple[Figure, AxisArray1D[Axes3]]: ...
98
102
 
99
103
  @overload
@@ -106,7 +110,9 @@ class Figure:
106
110
  sharey: Optional[Any] = ...,
107
111
  subplot_kw: _SubplotKw3D,
108
112
  figsize: Optional[tuple[float, float]] = ...,
109
- ) -> tuple[Figure, AxisArray1D[Axes3]]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
113
+ height_ratios: Optional[Sequence[float|int]]= ...,
114
+ width_ratios: Optional[Sequence[float|int]]= ...
115
+ ) -> AxisArray1D[Axes3]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
110
116
 
111
117
  @overload
112
118
  def subplots(
@@ -118,7 +124,9 @@ class Figure:
118
124
  sharey: Optional[Any] = ...,
119
125
  subplot_kw: _SubplotKw3D,
120
126
  figsize: Optional[tuple[float, float]] = ...,
121
- ) -> tuple[Figure, AxisArray2D[Axes3]]: ... # Catch-all fallback
127
+ height_ratios: Optional[Sequence[float|int]]= ...,
128
+ width_ratios: Optional[Sequence[float|int]]= ...
129
+ ) -> AxisArray2D[Axes3]: ... # Catch-all fallback
122
130
 
123
131
  @overload
124
132
  def subplots(
@@ -130,7 +138,9 @@ class Figure:
130
138
  sharey: Optional[Any] = ...,
131
139
  subplot_kw: Optional[dict[str, Any]] = ...,
132
140
  figsize: Optional[tuple[float, float]] = ...,
133
- ) -> tuple[Figure, Axes]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
141
+ height_ratios: Optional[Sequence[float|int]]= ...,
142
+ width_ratios: Optional[Sequence[float|int]]= ...
143
+ ) -> Axes: .. # type: ignore[overload-overlap, reportOverlappingOverload]
134
144
 
135
145
  @overload
136
146
  def subplots( # type: ignore[overload-overlap, reportOverlappingOverload]
@@ -142,7 +152,9 @@ class Figure:
142
152
  sharey: Optional[Any] = ...,
143
153
  subplot_kw: Optional[dict[str, Any]] = ...,
144
154
  figsize: Optional[tuple[float, float]] = ...,
145
- ) -> tuple[Figure, AxisArray1D[Axes]]: ...
155
+ height_ratios: Optional[Sequence[float|int]]= ...,
156
+ width_ratios: Optional[Sequence[float|int]]= ...
157
+ ) -> AxisArray1D[Axes]: ...
146
158
 
147
159
  @overload
148
160
  def subplots(
@@ -154,7 +166,9 @@ class Figure:
154
166
  sharey: Optional[Any] = ...,
155
167
  subplot_kw: Optional[dict[str, Any]] = ...,
156
168
  figsize: Optional[tuple[float, float]] = ...,
157
- ) -> tuple[Figure, AxisArray1D[Axes]]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
169
+ height_ratios: Optional[Sequence[float|int]]= ...,
170
+ width_ratios: Optional[Sequence[float|int]]= ...
171
+ ) -> AxisArray1D[Axes]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
158
172
 
159
173
  @overload
160
174
  def subplots(
@@ -166,7 +180,9 @@ class Figure:
166
180
  sharey: Optional[Any] = ...,
167
181
  subplot_kw: Optional[dict[str, Any]] = ...,
168
182
  figsize: Optional[tuple[float, float]] = ...,
169
- ) -> tuple[Figure, AxisArray2D[Axes]]: # type: ignore[overload-overlap]
183
+ height_ratios: Optional[Sequence[float|int]]= ...,
184
+ width_ratios: Optional[Sequence[float|int]]= ...
185
+ ) -> AxisArray2D[Axes]: # type: ignore[overload-overlap]
170
186
  """
171
187
  Create a figure and a set of subplots.
172
188
 
@@ -189,6 +205,12 @@ class Figure:
189
205
 
190
206
  figsize: tuple of 2 floats, optional
191
207
  Figure size in inches (width, height).
208
+
209
+ height_ratios : list of float, optional
210
+ Ratios for the heights of the rows. Must match the number of rows.
211
+
212
+ width_ratios : list of float, optional
213
+ Ratios for the widths of the columns. Must match the number of columns.
192
214
  """
193
215
  ...
194
216
 
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  import numpy as _np
2
4
 
3
5
  from tikzplot.styles import Styles
@@ -6,10 +8,11 @@ from .figure import Figure
6
8
  from .state import main_name, next_show_num
7
9
  from .config import TikzConfig
8
10
 
11
+ from .axes import Axes
9
12
  from .axes3d import Axes3
10
13
 
11
14
  _current_figure = None
12
- _current_axes = None
15
+ _current_axes: Optional[Axes | Axes3] = None
13
16
 
14
17
  style = Styles()
15
18
 
@@ -92,8 +95,11 @@ def subplots(nrows=1, ncols=1, sharex=None, sharey=None, subplot_kw=None, **kwar
92
95
  if isinstance(axs[0], _np.ndarray):
93
96
  _current_axes = axs[0, 0]
94
97
  else:
95
- _current_axes = axs[0]
98
+ a = axs[0]
99
+ assert isinstance(a, (Axes, Axes3))
100
+ _current_axes = a
96
101
  else:
102
+ assert isinstance(axs, (Axes, Axes3))
97
103
  _current_axes = axs
98
104
  return _current_figure, axs
99
105
 
@@ -198,6 +204,7 @@ def text(*args, **kwargs):
198
204
  def annotate(*args, **kwargs):
199
205
  _ensure_axes()
200
206
  assert _current_axes
207
+ assert isinstance(_current_axes, Axes), "annotate is not yet supported for 3D axes."
201
208
  return _current_axes.annotate(*args, **kwargs)
202
209
 
203
210
  def hlines(*args, **kwargs):
@@ -469,6 +476,8 @@ def show(standalone=None, print_requirements=False):
469
476
  def clf():
470
477
  assert _current_figure
471
478
  _current_figure.clear()
479
+ global _current_axes
480
+ _current_axes = None
472
481
 
473
482
  def gca():
474
483
  _ensure_axes()
@@ -78,6 +78,8 @@ def subplots(
78
78
  sharey: Optional[Any] = ...,
79
79
  subplot_kw: _SubplotKw3D,
80
80
  figsize: Optional[tuple[float, float]] = ...,
81
+ height_ratios: Optional[Sequence[float]] = ...,
82
+ width_ratios: Optional[Sequence[float]] = ...
81
83
  ) -> tuple[Figure, Axes3]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
82
84
 
83
85
  @overload
@@ -89,6 +91,8 @@ def subplots( # type: ignore[overload-overlap, reportOverlappingOverload]
89
91
  sharey: Optional[Any] = ...,
90
92
  subplot_kw: _SubplotKw3D,
91
93
  figsize: Optional[tuple[float, float]] = ...,
94
+ height_ratios: Optional[Sequence[float]] = ...,
95
+ width_ratios: Optional[Sequence[float]] = ...
92
96
  ) -> tuple[Figure, AxisArray1D[Axes3]]: ...
93
97
 
94
98
  @overload
@@ -100,6 +104,8 @@ def subplots(
100
104
  sharey: Optional[Any] = ...,
101
105
  subplot_kw: _SubplotKw3D,
102
106
  figsize: Optional[tuple[float, float]] = ...,
107
+ height_ratios: Optional[Sequence[float]] = ...,
108
+ width_ratios: Optional[Sequence[float]] = ...
103
109
  ) -> tuple[Figure, AxisArray1D[Axes3]]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
104
110
 
105
111
  @overload
@@ -111,6 +117,8 @@ def subplots(
111
117
  sharey: Optional[Any] = ...,
112
118
  subplot_kw: _SubplotKw3D,
113
119
  figsize: Optional[tuple[float, float]] = ...,
120
+ height_ratios: Optional[Sequence[float]] = ...,
121
+ width_ratios: Optional[Sequence[float]] = ...
114
122
  ) -> tuple[Figure, AxisArray2D[Axes3]]: ... # Catch-all fallback
115
123
 
116
124
  @overload
@@ -122,6 +130,8 @@ def subplots(
122
130
  sharey: Optional[Any] = ...,
123
131
  subplot_kw: Optional[dict[str, Any]] = ...,
124
132
  figsize: Optional[tuple[float, float]] = ...,
133
+ height_ratios: Optional[Sequence[float]] = ...,
134
+ width_ratios: Optional[Sequence[float]] = ...
125
135
  ) -> tuple[Figure, Axes]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
126
136
 
127
137
  @overload
@@ -133,6 +143,8 @@ def subplots( # type: ignore[overload-overlap, reportOverlappingOverload]
133
143
  sharey: Optional[Any] = ...,
134
144
  subplot_kw: Optional[dict[str, Any]] = ...,
135
145
  figsize: Optional[tuple[float, float]] = ...,
146
+ height_ratios: Optional[Sequence[float]] = ...,
147
+ width_ratios: Optional[Sequence[float]] = ...
136
148
  ) -> tuple[Figure, AxisArray1D[Axes]]: ...
137
149
 
138
150
  @overload
@@ -144,6 +156,8 @@ def subplots(
144
156
  sharey: Optional[Any] = ...,
145
157
  subplot_kw: Optional[dict[str, Any]] = ...,
146
158
  figsize: Optional[tuple[float, float]] = ...,
159
+ height_ratios: Optional[Sequence[float]] = ...,
160
+ width_ratios: Optional[Sequence[float]] = ...
147
161
  ) -> tuple[Figure, AxisArray1D[Axes]]: ... # type: ignore[overload-overlap, reportOverlappingOverload]
148
162
 
149
163
  @overload
@@ -155,6 +169,8 @@ def subplots(
155
169
  sharey: Optional[Any] = ...,
156
170
  subplot_kw: Optional[dict[str, Any]] = ...,
157
171
  figsize: Optional[tuple[float, float]] = ...,
172
+ height_ratios: Optional[Sequence[float]] = ...,
173
+ width_ratios: Optional[Sequence[float]] = ...
158
174
  ) -> tuple[Figure, AxisArray2D[Axes]]: # type: ignore[overload-overlap]
159
175
  """
160
176
  Create a figure and a set of subplots.
@@ -178,6 +194,12 @@ def subplots(
178
194
 
179
195
  figsize: tuple of 2 floats, optional
180
196
  Figure size in inches (width, height).
197
+
198
+ height_ratios : list of float, optional
199
+ Ratios for the heights of the rows. Must match the number of rows.
200
+
201
+ width_ratios : list of float, optional
202
+ Ratios for the widths of the columns. Must match the number of columns.
181
203
  """
182
204
  ...
183
205
 
@@ -304,7 +326,7 @@ def yscale(*args: Any, base: Optional[float] = ...) -> None:
304
326
  """
305
327
  ...
306
328
 
307
- def xticks(*ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., fontsize: Optional[float] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
329
+ def xticks(*ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., scaled: Optional[bool] = ..., fontsize: Optional[float] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
308
330
  """
309
331
  Set x-axis ticks and their labels.
310
332
 
@@ -315,6 +337,9 @@ def xticks(*ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., fontsize: O
315
337
 
316
338
  labels: sequence of str, optional
317
339
  Labels for the ticks. If not provided, the tick positions will be used as labels.
340
+
341
+ scaled: bool, optional
342
+ If False, automatic tick labels will be written without scale factor (e.g., 1e-3). If unchanged, LaTeX default is used.
318
343
 
319
344
  fontsize: float, optional
320
345
  Font size of the tick labels.
@@ -332,7 +357,7 @@ def xticks(*ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., fontsize: O
332
357
  Vertical alignment of the tick labels.
333
358
  """
334
359
  ...
335
- def yticks(*ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., fontsize: Optional[Literal["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"] | int] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
360
+ def yticks(*ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., scaled: Optional[bool] = ..., fontsize: Optional[Literal["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"] | int] = ..., color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., rotation: Optional[float|int]= ..., ha: Optional[Literal["left", "center", "right"]] = ..., horizontalalignment: Optional[Literal["left", "center", "right"]] = ..., va: Optional[Literal["top", "center", "bottom"]] = ..., verticalalignment: Optional[Literal["top", "center", "bottom"]] = ...) -> None:
336
361
  """
337
362
  Set y-axis ticks and their labels.
338
363
 
@@ -344,6 +369,9 @@ def yticks(*ticks: ArrayLike, labels: Optional[Sequence[str]] = ..., fontsize: O
344
369
  labels: sequence of str, optional
345
370
  Tick labels, if not provided, the tick positions are used as labels
346
371
 
372
+ scaled: bool, optional
373
+ If False, automatic tick labels will be written without scale factor (e.g., 1e-3). If None, LateX default is used.
374
+
347
375
  fontsize: FontSize or int, optional
348
376
  Font size of tick labels
349
377
 
@@ -395,7 +423,7 @@ def set_minorticks_num(num: int) -> None:
395
423
  num: int
396
424
  Number of minor ticks between major ticks.
397
425
  """
398
- def legend(*args: Any, loc: Optional[Union[int,str,Tuple[float,float]]] = ..., facecolor: Optional[ColorLike] = ..., edgecolor: Optional[ColorLike] = ..., labelcolor: Optional[ColorLike] = ..., frameon: Optional[bool] = ..., anchor: Optional[Literal["north", "south", "east", "west", "center", "north west", "north east", "south west", "south east"]] = ..., fontsize: Optional[FontSize] = ..., ncols: Optional[int] = 1, reverse: Optional[bool] = False) -> None:
426
+ def legend(*args: Any, loc: Optional[Union[int,Literal["upper right", "upper left", "lower left", "lower right", "right", "center left", "center right", "lower center", "upper center", "center"],Tuple[float,float]]] = ..., facecolor: Optional[ColorLike] = ..., edgecolor: Optional[ColorLike] = ..., labelcolor: Optional[ColorLike] = ..., frameon: Optional[bool] = ..., anchor: Optional[Literal["north", "south", "east", "west", "center", "north west", "north east", "south west", "south east"]] = ..., fontsize: Optional[FontSize] = ..., ncols: Optional[int] = 1, reverse: Optional[bool] = False) -> None:
399
427
  """
400
428
  Show legend for the selected axis. Despite arguments requires at least one plotted element on the axis (not necesarily with label) to show up (LaTeX does not allow legend on empty axis).
401
429
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tikzplot42
3
- Version: 0.6.4
3
+ Version: 0.6.5
4
4
  Summary: TikzPlot to make TikZ/PGFPlots plots with matplotlib.pyplot-like syntax.
5
5
  Author-email: Zan Ambrozic <zan.ambrozic7@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -696,6 +696,7 @@ License-File: LICENSE
696
696
  Requires-Dist: numpy
697
697
  Requires-Dist: matplotlib
698
698
  Requires-Dist: scipy
699
+ Requires-Dist: scikit-image
699
700
  Dynamic: license-file
700
701
 
701
702
  # TikzPlot
@@ -1,3 +1,4 @@
1
1
  numpy
2
2
  matplotlib
3
3
  scipy
4
+ scikit-image
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
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