tikzplot42 0.3.3__tar.gz → 0.3.6__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.3 → tikzplot42-0.3.6}/PKG-INFO +9 -6
  2. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/README.md +8 -5
  3. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/pyproject.toml +1 -1
  4. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/axes.py +20 -1
  5. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/axes.pyi +26 -0
  6. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/elements.py +50 -27
  7. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/figure.py +30 -1
  8. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/figure.pyi +6 -0
  9. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/plots.py +4 -0
  10. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/plots.pyi +20 -0
  11. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot42.egg-info/PKG-INFO +9 -6
  12. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test10.py +1 -1
  13. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test3.py +1 -0
  14. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/LICENSE +0 -0
  15. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/setup.cfg +0 -0
  16. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/__init__.py +0 -0
  17. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/__init__.pyi +0 -0
  18. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/axes3d.py +0 -0
  19. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/colorbar.py +0 -0
  20. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/colorbar.pyi +0 -0
  21. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/colors.py +0 -0
  22. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/colors.pyi +0 -0
  23. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/config.py +0 -0
  24. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/config.pyi +0 -0
  25. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/elements.pyi +0 -0
  26. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/latex_special.py +0 -0
  27. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/py.typed +0 -0
  28. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/state.py +0 -0
  29. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/state.pyi +0 -0
  30. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot/texts.py +0 -0
  31. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot42.egg-info/SOURCES.txt +0 -0
  32. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot42.egg-info/dependency_links.txt +0 -0
  33. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot42.egg-info/requires.txt +0 -0
  34. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/src/tikzplot42.egg-info/top_level.txt +0 -0
  35. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test1.py +0 -0
  36. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test2.py +0 -0
  37. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test4.py +0 -0
  38. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test5.py +0 -0
  39. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test6.py +0 -0
  40. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test7.py +0 -0
  41. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test8.py +0 -0
  42. {tikzplot42-0.3.3 → tikzplot42-0.3.6}/tests/test9.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tikzplot42
3
- Version: 0.3.3
3
+ Version: 0.3.6
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
@@ -706,7 +706,7 @@ A clean version of PltToTikz, this time as Python package. Easy to use: only rep
706
706
  Please let me know if you find any bugs or unexpected behaviour. Examples may be found in repository under `tests/` directory.
707
707
 
708
708
  <p align="center">
709
- <img src="https://github.com/ZanAmb/TikzPlot/blob/main/tests/demo.png" width="60%">
709
+ <img src="https://raw.githubusercontent.com/ZanAmb/TikzPlot/main/tests/demo.png" width="60%">
710
710
  </p>
711
711
 
712
712
  # Installation
@@ -737,17 +737,19 @@ Some basic plot commands are already implemented with commonly used arguments:
737
737
  - `semilogx()/semilogy()`,
738
738
  - `errorbar()`,
739
739
  - `stem()`,
740
- - `fill-between()`,
740
+ - `fill_between()`,
741
741
  - `hlines()/vlines()`,
742
742
  - `historgam()`,
743
743
  - `step()`,
744
744
  - `imshow()`,
745
- - `text()`.
745
+ - `text()`,
746
+ - `magnify()` (used to magnify part of a plot, but Tikz cannot handle `fill_between` if this one is used, which is a long known issue).
746
747
 
747
748
  #### Figures
748
749
  - `plt.figure()` (currently only to give you figure object or to set `figsize`),
749
750
  - `plt.subplot()`, `plt.subplots()` (with `sharex/sharey` fully implemented, projection `polar` and `3d` with basic support),
750
- - `set_size_inches()`.
751
+ - `set_size_inches()`,
752
+ - `delaxes()`.
751
753
 
752
754
  #### Styles
753
755
  If axes and plot have different name for command with same effect, both are implemented (e.g. `plt.xlim()` and `ax.set_xlim()`).
@@ -774,7 +776,8 @@ If axes and plot have different name for command with same effect, both are impl
774
776
  #### Colorbars
775
777
  Colorbars and colormaps are implemented a bit differently than in matplotlib (simplified):
776
778
  - if you use `imshow()`, you may use its return in `Colorbar()` (which you have to import as `from tikzplot import Colorbar`),
777
- - you may use `Colorbar(axis, cmap, lower, upper, ...)` for manual colorbar. Additional kwargs may also be used by `imshow()` return.
779
+ - you may use `Colorbar(axis, cmap, lower, upper, ...)` for manual colorbar. Additional kwargs may also be used by `imshow()` return,
780
+ - note that only one colorbar/colormap per axis is allowed (also if you use `scatter` with colormap/colorbar).
778
781
 
779
782
  #### TikzConfig
780
783
  For plot configurations (default sizes, paddings, etc.), use `from tikzplot import TikzConfig`:
@@ -4,7 +4,7 @@ A clean version of PltToTikz, this time as Python package. Easy to use: only rep
4
4
  Please let me know if you find any bugs or unexpected behaviour. Examples may be found in repository under `tests/` directory.
5
5
 
6
6
  <p align="center">
7
- <img src="https://github.com/ZanAmb/TikzPlot/blob/main/tests/demo.png" width="60%">
7
+ <img src="https://raw.githubusercontent.com/ZanAmb/TikzPlot/main/tests/demo.png" width="60%">
8
8
  </p>
9
9
 
10
10
  # Installation
@@ -35,17 +35,19 @@ Some basic plot commands are already implemented with commonly used arguments:
35
35
  - `semilogx()/semilogy()`,
36
36
  - `errorbar()`,
37
37
  - `stem()`,
38
- - `fill-between()`,
38
+ - `fill_between()`,
39
39
  - `hlines()/vlines()`,
40
40
  - `historgam()`,
41
41
  - `step()`,
42
42
  - `imshow()`,
43
- - `text()`.
43
+ - `text()`,
44
+ - `magnify()` (used to magnify part of a plot, but Tikz cannot handle `fill_between` if this one is used, which is a long known issue).
44
45
 
45
46
  #### Figures
46
47
  - `plt.figure()` (currently only to give you figure object or to set `figsize`),
47
48
  - `plt.subplot()`, `plt.subplots()` (with `sharex/sharey` fully implemented, projection `polar` and `3d` with basic support),
48
- - `set_size_inches()`.
49
+ - `set_size_inches()`,
50
+ - `delaxes()`.
49
51
 
50
52
  #### Styles
51
53
  If axes and plot have different name for command with same effect, both are implemented (e.g. `plt.xlim()` and `ax.set_xlim()`).
@@ -72,7 +74,8 @@ If axes and plot have different name for command with same effect, both are impl
72
74
  #### Colorbars
73
75
  Colorbars and colormaps are implemented a bit differently than in matplotlib (simplified):
74
76
  - if you use `imshow()`, you may use its return in `Colorbar()` (which you have to import as `from tikzplot import Colorbar`),
75
- - you may use `Colorbar(axis, cmap, lower, upper, ...)` for manual colorbar. Additional kwargs may also be used by `imshow()` return.
77
+ - you may use `Colorbar(axis, cmap, lower, upper, ...)` for manual colorbar. Additional kwargs may also be used by `imshow()` return,
78
+ - note that only one colorbar/colormap per axis is allowed (also if you use `scatter` with colormap/colorbar).
76
79
 
77
80
  #### TikzConfig
78
81
  For plot configurations (default sizes, paddings, etc.), use `from tikzplot import TikzConfig`:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tikzplot42"
7
- version = "0.3.3"
7
+ version = "0.3.6"
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" }
@@ -20,6 +20,8 @@ class BaseAxes:
20
20
  self._axis_args.add("/pgf/number format/use comma")
21
21
 
22
22
  self._add_legend = ""
23
+ self._coordinates = {}
24
+ self._cmap_bar = None
23
25
 
24
26
  def _plot(self, x, y, settings=None, xerr=None, yerr=None, **style):
25
27
  if not isinstance(self, Secondary) and self._polar:
@@ -71,6 +73,10 @@ class BaseAxes:
71
73
  vmin = kwargs.pop("vmin", min(c))
72
74
  vmax = kwargs.pop("vmax", max(c))
73
75
  kwargs["cmap"] = Colorbar(cmap=cmap, lower=vmin, upper=vmax)
76
+ if self._cmap_bar and self._cmap_bar != kwargs["cmap"]:
77
+ raise Warning("Multiple colormaps on same axis! Only one per axis is allowed.")
78
+ else:
79
+ self._cmap_bar = kwargs["cmap"]
74
80
  except: pass
75
81
 
76
82
  return self._plot(x, y, **kwargs, ls="", settings=["scatter"])
@@ -331,6 +337,13 @@ class BaseAxes:
331
337
  txt = Text(self, x, y, s, **kwargs)
332
338
  self._elements.append(txt)
333
339
 
340
+ def magnify(self, x_p, y_p, x_m, y_m, zoom, size, **kwargs):
341
+ kws = {"shape", "connect"}
342
+ kwargs = self._check_kwargs("magnify", kws, **kwargs)
343
+ n = self._fig._add_spy(zoom, size, **kwargs)
344
+ self._coordinates.update({f"spypoint{n}": (x_p,y_p)})
345
+ self._coordinates.update({f"spyviewr{n}": (x_m,y_m)})
346
+
334
347
  def _add_legend_entries(self):
335
348
  if self._add_legend == "": return ""
336
349
  axs, labs = self._add_legend
@@ -346,6 +359,9 @@ class BaseAxes:
346
359
  def _content_tex(self, filename):
347
360
  ouptut = "\n".join(e._to_tex(filename) for e in self._elements)
348
361
  ouptut += self._add_legend_entries()
362
+ for coord in self._coordinates:
363
+ x,y = self._coordinates[coord]
364
+ ouptut += f"\n\\coordinate ({coord}) at ({x},{y});"
349
365
  return ouptut
350
366
 
351
367
  def _get_hard_range(self,which):
@@ -659,7 +675,10 @@ class Axes(BaseAxes):
659
675
  if self._axis_options:
660
676
  if axis_opt_str: axis_opt_str += ",\n"
661
677
  axis_opt_str += ",\n".join(f"{k}={v}" for k, v in self._axis_options.items())
662
- axis_opt_str += self._colorbar
678
+ if self._colorbar:
679
+ axis_opt_str += self._colorbar
680
+ elif self._cmap_bar:
681
+ axis_opt_str += f",\n colormap={self._cmap_bar._generate_tex_colormap(self._cmap_bar._cmap)}"
663
682
  return axis_opt_str
664
683
 
665
684
 
@@ -313,6 +313,32 @@ class BaseAxes:
313
313
  Mark size in pt
314
314
  """
315
315
  ...
316
+
317
+ def spy(self, x_p: float, y_p: float, x_m: float, y_m: float, zoom: float, size: float, **kwargs) -> int:
318
+ """
319
+ Add a spy to the selected axis.
320
+
321
+ Parameters
322
+ ----------
323
+ x_p, y_p: float
324
+ Spy point coordinates in axis units
325
+
326
+ x_m, y_m: float
327
+ Spy view coordinates in cm
328
+
329
+ zoom: float
330
+ Spy zoom
331
+
332
+ size: float
333
+ Spy viewer size in cm
334
+
335
+ shape: {"circle"}, optional
336
+ Spy shape, default square
337
+
338
+ connect: bool, optional
339
+ Connect spy point and view with a line, default False
340
+ """
341
+ ...
316
342
 
317
343
  def set_ylabel(self, label: str) -> None:
318
344
  """
@@ -88,11 +88,15 @@ class BaseGraph:
88
88
  opts.append(ls)
89
89
 
90
90
  if "c" in self._style or "color" in self._style:
91
- if "scatter" in self._settings and self._colors is not None:
92
- if isinstance(self._colors[0], (int, float)):
93
- self._colors = [match_color(cmap.color(p)) for p in self._colors]
94
- else:
95
- self._colors = [match_color(p) for p in self._colors]
91
+ if "scatter" in self._settings:
92
+ if self._colors is not None:
93
+ if not isinstance(self._colors[0], (int, float)):
94
+ self._colors = [match_color(p) for p in self._colors]
95
+ elif self._sizes is not None:
96
+ c = self._style.get("c", self._style.get("color"))
97
+ sel_col = match_color(c)
98
+ if sel_col:
99
+ self._colors = [sel_col] * len(self._x)
96
100
  else:
97
101
  c = self._style.get("c", self._style.get("color"))
98
102
  sel_col = match_color(c)
@@ -163,19 +167,28 @@ class BaseGraph:
163
167
  if self._settings:
164
168
  opts = self._settings + opts
165
169
  if "scatter" in self._settings and (self._colors is not None or self._sizes is not None):
166
- last = 0
167
- for i in range(len(self._x)):
168
- st = ""
169
- if self._colors is not None:
170
- st = f"color={{{self._colors[i]}}},"
171
- if self._sizes is not None:
172
- st += f"mark size={self._sizes[i]:.9f}pt"
173
- if st not in self._st_dict:
174
- self._st_dict[st] = "s" + str(last+1)
175
- last += 1
176
- self._p_dict[i] = self._st_dict[st]
177
- opts.append("point meta=explicit symbolic")
178
- opts.append(f"scatter/classes={{\n" + ',\n'.join(f"{v}={{{k}}}" for k,v in self._st_dict.items()) + "\n}")
170
+ if self._sizes is not None:
171
+ if self._p_dict:
172
+ opts.append("visualization depends on=\\thisrow{size} \\as \\perpointsize,")
173
+ else:
174
+ opts.append("visualization depends on=\\thisrow{size} \\as \\perpointsize,\n scatter/@pre marker code/.append code={ \\pgfplotsset{mark size=\\perpointsize}},")
175
+ if "cmap" in self._style:
176
+ opts.append("scatter src=explicit")
177
+ else:
178
+ last = 0
179
+ for i in range(len(self._x)):
180
+ st = ""
181
+ if self._colors is not None:
182
+ if self._sizes is None:
183
+ st = f"color={{{self._colors[i]}}},"
184
+ else:
185
+ st = f"color={{{self._colors[i]}}},/tikz/mark size=\\perpointsize,"
186
+ if st not in self._st_dict:
187
+ self._st_dict[st] = "s" + str(last+1)
188
+ last += 1
189
+ self._p_dict[i] = self._st_dict[st]
190
+ opts.append("point meta=explicit symbolic")
191
+ opts.append(f"scatter/classes={{\n" + ',\n'.join(f"{v}={{{k}}}" for k,v in self._st_dict.items()) + "\n}")
179
192
  self._style_str = ",\n".join(str(o) for o in opts)
180
193
  return self._style_str
181
194
 
@@ -251,9 +264,6 @@ class Graph(BaseGraph):
251
264
  except: pass
252
265
  if self._colors is None and self._sizes is None:
253
266
  self._settings.remove("scatter")
254
- else:
255
- if self._colors is None:
256
- self._colors = style.get("c", style.get("color", self._axes._get_defcol())) * np.ones(len(self._x))
257
267
  else:
258
268
  self._special = coordinates
259
269
  self._label = None
@@ -277,8 +287,13 @@ class Graph(BaseGraph):
277
287
  else:
278
288
  cols.append("yerror")
279
289
  if "scatter" in self._settings:
280
- if self._p_dict:
281
- cols.append("label")
290
+ if "cmap" in self._style:
291
+ cols.append("color")
292
+ else:
293
+ if self._p_dict:
294
+ cols.append("label")
295
+ if self._sizes is not None:
296
+ cols.append("size")
282
297
  return " ".join(cols)
283
298
 
284
299
  def _rows(self):
@@ -296,8 +311,13 @@ class Graph(BaseGraph):
296
311
  else:
297
312
  line.append(self._yerr[i])
298
313
  if "scatter" in self._settings:
299
- if self._p_dict:
300
- line.append(self._p_dict[i])
314
+ if "cmap" in self._style:
315
+ line.append(self._colors[i])
316
+ else:
317
+ if self._p_dict:
318
+ line.append(self._p_dict[i])
319
+ if self._sizes is not None:
320
+ line.append(f"{self._sizes[i]:.9f} pt")
301
321
  rows.append(" ".join(str(v) for v in line))
302
322
  return "\n".join(rows)
303
323
 
@@ -312,8 +332,11 @@ class Graph(BaseGraph):
312
332
  table_opts += ",x error=xerror"
313
333
  if self._yerr is not None:
314
334
  table_opts += ",y error=yerror"
315
- if "scatter" in self._settings and self._p_dict:
316
- table_opts += ",meta=label"
335
+ if "scatter" in self._settings:
336
+ if "cmap" in self._style:
337
+ table_opts += ",meta=color"
338
+ elif self._p_dict:
339
+ table_opts += ",meta=label"
317
340
  datapoints = f"{header}\n{rows}\n"
318
341
  if TikzConfig.SAVE_DATAPOINTS:
319
342
  datapoints = self._save_data(datapoints, filename)
@@ -28,6 +28,7 @@ class Figure:
28
28
  self._col_dict = {}
29
29
 
30
30
  self._globals = set()
31
+ self._spies = []
31
32
 
32
33
  def add_subplot(self, nrows=1, ncols=1, index=1, sharex=None, sharey=None, projection=None, polar=False):
33
34
  if projection=="3d":
@@ -70,6 +71,11 @@ class Figure:
70
71
  ax._update_size()
71
72
  except:
72
73
  pass
74
+
75
+ def delaxes(self, ax):
76
+ if ax in self._axes:
77
+ self._axes.remove(ax)
78
+ del ax
73
79
 
74
80
  def _compute_group_spacing(self):
75
81
  grid = np.zeros((self._nrows, self._ncols, 4))
@@ -190,6 +196,21 @@ class Figure:
190
196
  for group in shared_y:
191
197
  set_ax_ranges("y", group)
192
198
 
199
+ def _add_spy(self, zoom, size, **kwargs):
200
+ sp_str = f"\\spy [size={size}cm, magnification={zoom}"
201
+ bck = ""
202
+ n = len(self._spies)
203
+ if "shape" in kwargs and kwargs["shape"] == "circle":
204
+ sp_str += ", circle"
205
+ bck = f"\\fill[white] (spyviewr{n}) circle ({size/2}cm);\n"
206
+ else:
207
+ bck = f"\\fill[white] ($(spyviewr{n}) + (-{size/2}cm,-{size/2}cm)$) rectangle ($(spyviewr{n}) + ({size/2}cm,{size/2}cm)$);\n"
208
+ if "connect" in kwargs and kwargs["connect"]:
209
+ sp_str += ", connect spies"
210
+ sp_str += f"] on (spypoint{n}) in node at (spyviewr{n});"
211
+ self._spies.append(bck + sp_str)
212
+ return n
213
+
193
214
  def _reduce_points(self):
194
215
  counts = [0]
195
216
  for ax in self._axes:
@@ -224,14 +245,20 @@ class Figure:
224
245
  if TikzConfig.USE_GROUPPLOTS:
225
246
  preambule += "\\usepgfplotslibrary{groupplots}\n"
226
247
  preambule += "\\usepgfplotslibrary{fillbetween}\n"
248
+ preambule += "\\usepgfplotslibrary{polar}\n"
227
249
  preambule += f"\\pgfplotsset{{compat={TikzConfig.TIKZ_COMPAT}}}\n"
228
250
  if TikzConfig.USE_XCOLOR:
229
251
  preambule += "\\usepackage{xcolor}\n"
252
+ if self._spies:
253
+ preambule += "\\usetikzlibrary{spy}\n"
230
254
  preambule += "\\begin{document}\n"
231
255
 
232
256
  lines = [g for g in self._globals]
233
257
  lines2 = []
234
- lines.append("\\begin{tikzpicture}")
258
+ if self._spies:
259
+ lines.append("\\begin{tikzpicture}[spy using outlines={}]")
260
+ else:
261
+ lines.append("\\begin{tikzpicture}")
235
262
  nrows = self._axes[0]._get_nrows()
236
263
  ncols = self._axes[0]._get_ncols()
237
264
  if TikzConfig.USE_GROUPPLOTS:
@@ -248,6 +275,8 @@ class Figure:
248
275
  if TikzConfig.USE_GROUPPLOTS:
249
276
  lines.append("\\end{groupplot}")
250
277
  lines += lines2
278
+ for spy in self._spies:
279
+ lines.append(spy)
251
280
  lines.append("\\end{tikzpicture}")
252
281
  for c in self._col_dict:
253
282
  r,g,b=self._col_dict[c]
@@ -20,6 +20,12 @@ class Figure:
20
20
  Set figure size (w,h).
21
21
  """
22
22
  ...
23
+
24
+ def delaxes(self, ax:Axes) -> None:
25
+ """
26
+ Delete axis from figure.
27
+ """
28
+ ...
23
29
  def clear(self) -> None:
24
30
  """
25
31
  Clear figure.
@@ -154,6 +154,10 @@ def step(*args, **kwargs):
154
154
  _ensure_axes()
155
155
  return _current_axes.step(*args, **kwargs)
156
156
 
157
+ def magnify(*args, **kwargs):
158
+ _ensure_axes()
159
+ return _current_axes.magnify(*args, **kwargs)
160
+
157
161
  def xticks(*args, **kwargs):
158
162
  _ensure_axes()
159
163
  _current_axes.set_xticks(*args, **kwargs)
@@ -465,6 +465,26 @@ def step(self, x: ArrayLike, y: ArrayLike, *args: Any, where: Literal["pre","pos
465
465
  """
466
466
  ...
467
467
 
468
+ def spy(self, x_p: float, y_p: float, x_m: float, y_m: float, zoom: float, size: float, **kwargs) -> int:
469
+ """
470
+ Add a spy to the selected axis.
471
+ Parameters
472
+ ----------
473
+ x_p, y_p: float
474
+ Spy point coordinates in axis units
475
+ x_m, y_m: float
476
+ Spy view coordinates in cm
477
+ zoom: float
478
+ Spy zoom
479
+ size: float
480
+ Spy viewer size in cm
481
+ shape: {"circle"}, optional
482
+ Spy shape, default square
483
+ connect: bool, optional
484
+ Connect spy point and view with a line, default False
485
+ """
486
+ ...
487
+
468
488
  def hlines(
469
489
  self,
470
490
  y: Union[float, Sequence[float]],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tikzplot42
3
- Version: 0.3.3
3
+ Version: 0.3.6
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
@@ -706,7 +706,7 @@ A clean version of PltToTikz, this time as Python package. Easy to use: only rep
706
706
  Please let me know if you find any bugs or unexpected behaviour. Examples may be found in repository under `tests/` directory.
707
707
 
708
708
  <p align="center">
709
- <img src="https://github.com/ZanAmb/TikzPlot/blob/main/tests/demo.png" width="60%">
709
+ <img src="https://raw.githubusercontent.com/ZanAmb/TikzPlot/main/tests/demo.png" width="60%">
710
710
  </p>
711
711
 
712
712
  # Installation
@@ -737,17 +737,19 @@ Some basic plot commands are already implemented with commonly used arguments:
737
737
  - `semilogx()/semilogy()`,
738
738
  - `errorbar()`,
739
739
  - `stem()`,
740
- - `fill-between()`,
740
+ - `fill_between()`,
741
741
  - `hlines()/vlines()`,
742
742
  - `historgam()`,
743
743
  - `step()`,
744
744
  - `imshow()`,
745
- - `text()`.
745
+ - `text()`,
746
+ - `magnify()` (used to magnify part of a plot, but Tikz cannot handle `fill_between` if this one is used, which is a long known issue).
746
747
 
747
748
  #### Figures
748
749
  - `plt.figure()` (currently only to give you figure object or to set `figsize`),
749
750
  - `plt.subplot()`, `plt.subplots()` (with `sharex/sharey` fully implemented, projection `polar` and `3d` with basic support),
750
- - `set_size_inches()`.
751
+ - `set_size_inches()`,
752
+ - `delaxes()`.
751
753
 
752
754
  #### Styles
753
755
  If axes and plot have different name for command with same effect, both are implemented (e.g. `plt.xlim()` and `ax.set_xlim()`).
@@ -774,7 +776,8 @@ If axes and plot have different name for command with same effect, both are impl
774
776
  #### Colorbars
775
777
  Colorbars and colormaps are implemented a bit differently than in matplotlib (simplified):
776
778
  - if you use `imshow()`, you may use its return in `Colorbar()` (which you have to import as `from tikzplot import Colorbar`),
777
- - you may use `Colorbar(axis, cmap, lower, upper, ...)` for manual colorbar. Additional kwargs may also be used by `imshow()` return.
779
+ - you may use `Colorbar(axis, cmap, lower, upper, ...)` for manual colorbar. Additional kwargs may also be used by `imshow()` return,
780
+ - note that only one colorbar/colormap per axis is allowed (also if you use `scatter` with colormap/colorbar).
778
781
 
779
782
  #### TikzConfig
780
783
  For plot configurations (default sizes, paddings, etc.), use `from tikzplot import TikzConfig`:
@@ -20,5 +20,5 @@ colors = theta
20
20
  fig = plt.figure(figsize=(6, 6))
21
21
  ax = fig.add_subplot(projection='polar')
22
22
  #cbar = Colorbar(cmap='hsv', lower=0, upper=max(theta))
23
- c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
23
+ c = ax.scatter(theta, r, c="blue", s=100, alpha=0.75)
24
24
  plt.savefig("figure.tex")
@@ -49,6 +49,7 @@ y2 = [25, 20, 15, 10, 5]
49
49
 
50
50
  ax5.plot(x, y1, color='cyan', linestyle='--', marker='o')
51
51
  ax5.plot(x, y2, color='purple', linestyle='-', marker='x')
52
+ ax5.magnify(3.5, 12, 2, 10, 5, 2, connect=True)
52
53
 
53
54
  ax1.errorbar(points[:,0], ys, yerr=yerr, marker="o", linestyle="", color="blue", label="Meritve")
54
55
  lims = np.array([points[0,0], points[-1,0]])
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