tikzplot42 0.3.7__tar.gz → 0.3.9__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 (42) hide show
  1. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/PKG-INFO +1 -1
  2. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/pyproject.toml +1 -1
  3. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/axes.py +10 -6
  4. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/config.py +1 -1
  5. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/elements.py +2 -2
  6. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/figure.py +13 -0
  7. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/texts.py +13 -3
  8. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot42.egg-info/PKG-INFO +1 -1
  9. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test7.py +3 -1
  10. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/LICENSE +0 -0
  11. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/README.md +0 -0
  12. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/setup.cfg +0 -0
  13. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/__init__.py +0 -0
  14. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/__init__.pyi +0 -0
  15. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/axes.pyi +0 -0
  16. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/axes3d.py +0 -0
  17. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/colorbar.py +0 -0
  18. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/colorbar.pyi +0 -0
  19. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/colors.py +0 -0
  20. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/colors.pyi +0 -0
  21. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/config.pyi +0 -0
  22. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/elements.pyi +0 -0
  23. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/figure.pyi +0 -0
  24. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/latex_special.py +0 -0
  25. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/plots.py +0 -0
  26. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/plots.pyi +0 -0
  27. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/py.typed +0 -0
  28. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/state.py +0 -0
  29. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot/state.pyi +0 -0
  30. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot42.egg-info/SOURCES.txt +0 -0
  31. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot42.egg-info/dependency_links.txt +0 -0
  32. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot42.egg-info/requires.txt +0 -0
  33. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/src/tikzplot42.egg-info/top_level.txt +0 -0
  34. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test1.py +0 -0
  35. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test10.py +0 -0
  36. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test2.py +0 -0
  37. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test3.py +0 -0
  38. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test4.py +0 -0
  39. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test5.py +0 -0
  40. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test6.py +0 -0
  41. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test8.py +0 -0
  42. {tikzplot42-0.3.7 → tikzplot42-0.3.9}/tests/test9.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tikzplot42
3
- Version: 0.3.7
3
+ Version: 0.3.9
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tikzplot42"
7
- version = "0.3.7"
7
+ version = "0.3.9"
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" }
@@ -258,13 +258,13 @@ class BaseAxes:
258
258
  kwargs["fmt"] = args[0]
259
259
  return self._plot(x,y,settings=settings, **kwargs)
260
260
 
261
- def axvline(self, x, ymin=0, ymax=0, **kwargs):
261
+ def axvline(self, x, ymin=0, ymax=1, **kwargs):
262
262
  kws = {"fmt", "base", "alpha", "color", "c", "linestyle", "ls", "linewidth", "lw", "label"}
263
263
  kwargs = self._check_kwargs("axvline", kws, **kwargs)
264
264
  self._ext_ymin = self._ext_ymax = True
265
265
  self._plot(x, (ymin, ymax), settings="axvline", **kwargs)
266
266
 
267
- def axhline(self, y, xmin=0, xmax=0, **kwargs):
267
+ def axhline(self, y, xmin=0, xmax=1, **kwargs):
268
268
  kws = {"fmt", "base", "alpha", "color", "c", "linestyle", "ls", "linewidth", "lw", "label"}
269
269
  kwargs = self._check_kwargs("axhline", kws, **kwargs)
270
270
  if isinstance(self, Secondary):
@@ -395,10 +395,15 @@ class BaseAxes:
395
395
  for i in range(len(labs)):
396
396
  self._elements[i]._set_label(tex_text(labs[i]))
397
397
 
398
- def text(self, x, y, s, **kwargs):
398
+ def text(self, x, y, s, on_top=True, **kwargs):
399
399
  kws = {"alpha", "color", "c", "fontsize", "size", "backgroundcolor", "horizontalalignment", "ha", "verticalalignment", "va", "rotation", "label"}
400
400
  kwargs = self._check_kwargs("text", kws, **kwargs)
401
- txt = Text(self, x, y, s, **kwargs)
401
+ if on_top:
402
+ coord = self._fig._next_coordinate_name()
403
+ txt = Text(self, x, y, coord, s, **kwargs)
404
+ self._fig._add_text(txt)
405
+ else:
406
+ txt = Text(self, x, y, None, s, **kwargs)
402
407
  self._elements.append(txt)
403
408
 
404
409
  def magnify(self, x_p, y_p, x_m, y_m, zoom, size, **kwargs):
@@ -584,7 +589,6 @@ class Axes(BaseAxes):
584
589
  #kws = {"fmt", "alpha", "color", "c", "linestyle", "ls", "linewidth", "lw", "marker", "markersize", "ms", "label"}
585
590
  #kwargs = self._check_kwargs("imshow", kws, **kwargs)
586
591
  self._imshow = (args, kwargs)
587
- #self._axis_args.add("axis on top")
588
592
  self._axis_options["enlargelimits"] = "false"
589
593
  #self._fig._add_global("\\pgfplotsset{set layers}")
590
594
  data = args[0]
@@ -739,7 +743,7 @@ class Axes(BaseAxes):
739
743
  if TikzConfig.SCHOOL_AXIS:
740
744
  axis_opt_str += f",\n set layers,\n axis line style={{on layer=axis foreground}}"
741
745
  else:
742
- axis_opt_str += f",\n axis on top"
746
+ axis_opt_str += f",\n set layers=standard, cell picture=true, grid style={{on layer=axis grid}}"
743
747
  if self._ext_xmin or self._ext_xmax:
744
748
  lower = self._get_range("xmin")
745
749
  upper = self._get_range("xmax")
@@ -29,7 +29,7 @@ class _TikzConfig:
29
29
 
30
30
  self.SHARED_AXIS_REL_MARGIN: float = 0.08
31
31
 
32
- self.SAVE_DATAPOINTS: bool = True
32
+ self.SAVE_DATAPOINTS: bool = False
33
33
  self.DATAPOINTS_DIR: str = "datapoints" # ignored if SAVE_DATAPOINTS == False
34
34
  self.UPDATE_DATA_ONLY: bool = False # ignored if SAVE_DATAPOINTS == False
35
35
  self.UPDATE_STYLE_ONLY: bool = False # ignored if SAVE_DATAPOINTS == False
@@ -138,8 +138,8 @@ class BaseGraph:
138
138
  if "alpha" in self._style:
139
139
  self._opacity = self._style["alpha"]
140
140
 
141
- #if "onlayer" in self._style:
142
- # opts.append(f"on layer={self._style["onlayer"]}")
141
+ if "onlayer" in self._style:
142
+ opts.append(f"on layer={self._style['onlayer']}")
143
143
 
144
144
  if self._opacity < 1:
145
145
  opts.append(f"opacity={self._opacity}")
@@ -30,6 +30,10 @@ class Figure:
30
30
  self._globals = set()
31
31
  self._spies = []
32
32
 
33
+ self._num_coordinates = 0
34
+
35
+ self.texts = []
36
+
33
37
  self._lims = {"xmin": {}, "xmax": {}, "ymin": {}, "ymax": {}}
34
38
 
35
39
  def add_subplot(self, nrows=1, ncols=1, index=1, sharex=None, sharey=None, projection=None, polar=False):
@@ -301,6 +305,8 @@ class Figure:
301
305
  lines += lines2
302
306
  for spy in self._spies:
303
307
  lines.append(spy)
308
+ for text in self.texts:
309
+ lines.append(text._to_tex_fin())
304
310
  lines.append("\\end{tikzpicture}")
305
311
  for c in self._col_dict:
306
312
  r,g,b=self._col_dict[c]
@@ -340,3 +346,10 @@ class Figure:
340
346
 
341
347
  def _add_global(self, setting):
342
348
  self._globals.add(setting)
349
+
350
+ def _next_coordinate_name(self):
351
+ self._num_coordinates += 1
352
+ return f"(coordinate{self._num_coordinates})"
353
+
354
+ def _add_text(self, text):
355
+ self.texts.append(text)
@@ -1,10 +1,11 @@
1
1
  from .colors import _tex_color
2
2
 
3
3
  class Text:
4
- def __init__(self, ax, x, y, s, **kwargs):
4
+ def __init__(self, ax, x, y, coordinate, s, **kwargs):
5
5
  self._axes = ax
6
6
  self._x = x
7
7
  self._y = y
8
+ self._coordinate = coordinate
8
9
  self._s = s
9
10
  self._kwargs = kwargs
10
11
  self._color = False
@@ -78,10 +79,19 @@ class Text:
78
79
 
79
80
  def _to_tex(self, _):
80
81
  if self._visible:
81
- return f"\\node[{self._style_string()}] at (axis cs:{self._x},{self._y}) {{{self._fsize or ''}{self._s}}};"
82
+ if self._coordinate is not None:
83
+ return f"\\coordinate {self._coordinate} at (axis cs:{self._x},{self._y});"
84
+ else:
85
+ return f"\\node[{self._style_string()}] at (axis cs:{self._x},{self._y}) {{{self._fsize or ''}{self._s}}};"
86
+
87
+ else:
88
+ return ""
89
+ def _to_tex_fin(self):
90
+ if self._visible:
91
+ if self._coordinate is not None:
92
+ return f"\\node[{self._style_string()}] at {self._coordinate} {{{self._fsize or ''}{self._s}}};"
82
93
  else:
83
94
  return ""
84
-
85
95
  def _set_label(self, label):
86
96
  self._label = label
87
97
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tikzplot42
3
- Version: 0.3.7
3
+ Version: 0.3.9
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
@@ -23,8 +23,10 @@ fig, axs = plt.subplots(3,2)
23
23
  # =========================
24
24
  ax = axs[0, 0]
25
25
  ax.plot(x, y, color="blue", lw=1.5, label="sin(x)")
26
+ ax.text(1.5, 0.5, r"text $\alpha$", color="blue", ha="center", on_top=False, va="center", backgroundcolor="cyan", rotation=30)
26
27
  ax.plot(x, y2, ls="--", color="red", label="cos(x)")
27
- ax.text(1.5, 0.5, r"text $\alpha$", color="blue", ha="center", va="center", backgroundcolor="cyan", rotation=30)
28
+ ax.text(1.5, -0.5, r"text $\beta$", color="teal", ha="center", va="center", rotation=-70)
29
+
28
30
  ax.grid()
29
31
  ax.legend(loc="upper right")
30
32
  # =========================
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