tikzplot42 0.4.6__tar.gz → 0.4.7__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.
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/PKG-INFO +6 -3
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/README.md +5 -2
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/pyproject.toml +1 -1
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/axes.py +3 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/elements.py +1 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/figure.py +47 -23
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/figure.pyi +4 -2
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/plots.py +4 -4
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/plots.pyi +21 -3
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot42.egg-info/PKG-INFO +6 -3
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test2.py +1 -1
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/LICENSE +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/setup.cfg +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/__init__.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/__init__.pyi +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/axes.pyi +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/axes3d.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/axes3d.pyi +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/colorbar.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/colorbar.pyi +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/colors.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/config.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/config.pyi +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/elements.pyi +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/latex_special.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/py.typed +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/state.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/styles.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/styles.pyi +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot/texts.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot42.egg-info/SOURCES.txt +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot42.egg-info/dependency_links.txt +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot42.egg-info/requires.txt +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/src/tikzplot42.egg-info/top_level.txt +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test1.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test10.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test11.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test12.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test13.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test3.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test4.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test5.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test6.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test7.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test8.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test9.py +0 -0
- {tikzplot42-0.4.6 → tikzplot42-0.4.7}/tests/test_styles.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tikzplot42
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.7
|
|
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
|
|
@@ -717,13 +717,15 @@ Alternativley, download this package and install using: `pip install [path]`, wh
|
|
|
717
717
|
Instead of using `import matplotlib.pyplot (as plt)`, use `import tikzplot.plots (as plt)`.
|
|
718
718
|
|
|
719
719
|
## LaTeX requirements
|
|
720
|
+
All required packages are automatically detected and can be printed at save using kwarg `print_requirements=True` (for standalone files, preambule is automatically added).
|
|
720
721
|
- `\usepackage{tikz}`,
|
|
721
722
|
- `\usepackage{pgfplots}`,
|
|
722
723
|
- `\pgfplotsset{compat=1.18}` (may be lower, but compilation is not guaranteed),
|
|
723
724
|
- `\usepgfplotslibrary{fillbetween}` (if you use fill-between plots),
|
|
724
725
|
- `\usepgfplotslibrary{groupplots}` (recommended for best results, enabled by default, may be avoided by setting TikzConfig USE_GROUPPLOTS=False),
|
|
725
726
|
- `\usepackage{xcolor}` (recommended for best colors, works without but needs change of TikzConfig USE_XCOLOR=False),
|
|
726
|
-
- `\usepgfplotslibrary{polar}` required for polar axis
|
|
727
|
+
- `\usepgfplotslibrary{polar}` required for polar axis,
|
|
728
|
+
- `\usetikzlibrary{patterns.meta}` for hatch patterns (available for fill_between, hist and axvspan/axhspan).
|
|
727
729
|
|
|
728
730
|
Export using `plt.savefig("example_graph.tex")` (recommended) or `plt.show()`.
|
|
729
731
|
Then use the generated file as `\input{example_graph.tex}`.
|
|
@@ -768,7 +770,7 @@ If axes and plot have different name for command with same effect, both are impl
|
|
|
768
770
|
There is a limited support for built-in styles (e.g. `plt.style.use("default")`), you may also define your own style using `plt.style.set_profile()`. Currently supported features are: color cycle (hex colors sequence), line width (in pt), grid (with matplotlib kwargs), background (latex style key=value), additional settings (raw latex code for optional arguments to axis: key=value).
|
|
769
771
|
|
|
770
772
|
#### Supported common **kwargs
|
|
771
|
-
- `color/c
|
|
773
|
+
- `color/c`,
|
|
772
774
|
- `linestyle/ls`,
|
|
773
775
|
- `linewidth/ls`,
|
|
774
776
|
- `fmt`,
|
|
@@ -790,6 +792,7 @@ For plot configurations (default sizes, paddings, etc.), use `from tikzplot impo
|
|
|
790
792
|
Currently supported parameters are listed with their default values in `src/tikzplot/config.py`.
|
|
791
793
|
|
|
792
794
|
## More features coming soon...
|
|
795
|
+
- bar plots,
|
|
793
796
|
- more developed styles,
|
|
794
797
|
- improved 3D plots (currently only basic support: plot, errorbar, fill_between, scatter, plot_wireframe, plot_surface),
|
|
795
798
|
- ...
|
|
@@ -15,13 +15,15 @@ Alternativley, download this package and install using: `pip install [path]`, wh
|
|
|
15
15
|
Instead of using `import matplotlib.pyplot (as plt)`, use `import tikzplot.plots (as plt)`.
|
|
16
16
|
|
|
17
17
|
## LaTeX requirements
|
|
18
|
+
All required packages are automatically detected and can be printed at save using kwarg `print_requirements=True` (for standalone files, preambule is automatically added).
|
|
18
19
|
- `\usepackage{tikz}`,
|
|
19
20
|
- `\usepackage{pgfplots}`,
|
|
20
21
|
- `\pgfplotsset{compat=1.18}` (may be lower, but compilation is not guaranteed),
|
|
21
22
|
- `\usepgfplotslibrary{fillbetween}` (if you use fill-between plots),
|
|
22
23
|
- `\usepgfplotslibrary{groupplots}` (recommended for best results, enabled by default, may be avoided by setting TikzConfig USE_GROUPPLOTS=False),
|
|
23
24
|
- `\usepackage{xcolor}` (recommended for best colors, works without but needs change of TikzConfig USE_XCOLOR=False),
|
|
24
|
-
- `\usepgfplotslibrary{polar}` required for polar axis
|
|
25
|
+
- `\usepgfplotslibrary{polar}` required for polar axis,
|
|
26
|
+
- `\usetikzlibrary{patterns.meta}` for hatch patterns (available for fill_between, hist and axvspan/axhspan).
|
|
25
27
|
|
|
26
28
|
Export using `plt.savefig("example_graph.tex")` (recommended) or `plt.show()`.
|
|
27
29
|
Then use the generated file as `\input{example_graph.tex}`.
|
|
@@ -66,7 +68,7 @@ If axes and plot have different name for command with same effect, both are impl
|
|
|
66
68
|
There is a limited support for built-in styles (e.g. `plt.style.use("default")`), you may also define your own style using `plt.style.set_profile()`. Currently supported features are: color cycle (hex colors sequence), line width (in pt), grid (with matplotlib kwargs), background (latex style key=value), additional settings (raw latex code for optional arguments to axis: key=value).
|
|
67
69
|
|
|
68
70
|
#### Supported common **kwargs
|
|
69
|
-
- `color/c
|
|
71
|
+
- `color/c`,
|
|
70
72
|
- `linestyle/ls`,
|
|
71
73
|
- `linewidth/ls`,
|
|
72
74
|
- `fmt`,
|
|
@@ -88,6 +90,7 @@ For plot configurations (default sizes, paddings, etc.), use `from tikzplot impo
|
|
|
88
90
|
Currently supported parameters are listed with their default values in `src/tikzplot/config.py`.
|
|
89
91
|
|
|
90
92
|
## More features coming soon...
|
|
93
|
+
- bar plots,
|
|
91
94
|
- more developed styles,
|
|
92
95
|
- improved 3D plots (currently only basic support: plot, errorbar, fill_between, scatter, plot_wireframe, plot_surface),
|
|
93
96
|
- ...
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tikzplot42"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.7"
|
|
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" }
|
|
@@ -147,6 +147,7 @@ class BaseAxes:
|
|
|
147
147
|
else:
|
|
148
148
|
return None
|
|
149
149
|
assert self._fig is not None
|
|
150
|
+
self._fig._add_required_package("\\usepgfplotslibrary{fillbetween}")
|
|
150
151
|
name1 = self._fig._get_free_path_name()
|
|
151
152
|
name2 = self._fig._get_free_path_name()
|
|
152
153
|
if isinstance(y1, (int, float)):
|
|
@@ -1002,6 +1003,8 @@ class Axes(BaseAxes):
|
|
|
1002
1003
|
def _to_tex(self, filename, single):
|
|
1003
1004
|
lines = []
|
|
1004
1005
|
lines2 = []
|
|
1006
|
+
if self._polar:
|
|
1007
|
+
self._fig._add_required_package("\\usepgfplotslibrary{polar}")
|
|
1005
1008
|
if self._polar and TikzConfig.USE_GROUPPLOTS and not single:
|
|
1006
1009
|
lines.append(f"\\nextgroupplot[alias={self._axis_options['alias']}, width={self._width}, height={self._height}, hide axis]")
|
|
1007
1010
|
lines2.append("\\begin{polaraxis}")
|
|
@@ -173,6 +173,7 @@ class BaseGraph:
|
|
|
173
173
|
opts["color"] = f"{{{match_color(f'C{self._axes._get_defcol()}')}}}"
|
|
174
174
|
|
|
175
175
|
if "hatch" in self._style:
|
|
176
|
+
self._axes._fig._add_required_package("\\usetikzlibrary{patterns.meta}")
|
|
176
177
|
def match_hatch(input):
|
|
177
178
|
chars = list(input)
|
|
178
179
|
hatches = []
|
|
@@ -37,6 +37,8 @@ class Figure:
|
|
|
37
37
|
|
|
38
38
|
self._lims = {"xmin": {}, "xmax": {}, "ymin": {}, "ymax": {}}
|
|
39
39
|
|
|
40
|
+
self._required_packages: dict[str, int] = {} # int for priority: 0-tikz, 1-pgfplots, 2-other packages, 3-pgfplotsset, 4-tikzlibraries, 5-pgfplotslibraries
|
|
41
|
+
|
|
40
42
|
def add_subplot(self, nrows=1, ncols=1, index=1, sharex=None, sharey=None, projection=None, polar=False):
|
|
41
43
|
if projection=="3d":
|
|
42
44
|
ax = Axes3(nrows, ncols, index, self)
|
|
@@ -261,32 +263,13 @@ class Figure:
|
|
|
261
263
|
for ax in self._axes:
|
|
262
264
|
ax._reduce_points(limit)
|
|
263
265
|
|
|
264
|
-
def _to_tex(self, filename, png=False):
|
|
266
|
+
def _to_tex(self, filename, png=False, standalone=None, print_requirements=False):
|
|
265
267
|
single = self._nrows * self._ncols == 1
|
|
266
268
|
if not self._axes:
|
|
267
269
|
return ""
|
|
268
270
|
self._shared_ranges()
|
|
269
271
|
if TikzConfig.REDUCE_NUM_POINTS:
|
|
270
272
|
self._reduce_points()
|
|
271
|
-
preambule = ""
|
|
272
|
-
if TikzConfig.STANDALONE:
|
|
273
|
-
if png:
|
|
274
|
-
preambule += "\\documentclass[tikz,border=2pt,convert={density=300,outext=.png}]{standalone}\n"
|
|
275
|
-
else:
|
|
276
|
-
preambule += "\\documentclass[tikz,border=2pt]{standalone}\n"
|
|
277
|
-
preambule += "\\usepackage{tikz}\n"
|
|
278
|
-
preambule += "\\usepackage{pgfplots}\n"
|
|
279
|
-
if TikzConfig.USE_GROUPPLOTS and not single:
|
|
280
|
-
preambule += "\\usepgfplotslibrary{groupplots}\n"
|
|
281
|
-
preambule += "\\usepgfplotslibrary{fillbetween}\n"
|
|
282
|
-
preambule += "\\usepgfplotslibrary{polar}\n"
|
|
283
|
-
preambule += f"\\pgfplotsset{{compat={TikzConfig.TIKZ_COMPAT}}}\n"
|
|
284
|
-
if TikzConfig.USE_XCOLOR:
|
|
285
|
-
preambule += "\\usepackage{xcolor}\n"
|
|
286
|
-
if self._spies:
|
|
287
|
-
preambule += "\\usetikzlibrary{spy}\n"
|
|
288
|
-
preambule += "\\begin{document}\n"
|
|
289
|
-
|
|
290
273
|
lines0 = [g for g in self._globals]
|
|
291
274
|
lines = []
|
|
292
275
|
lines2 = []
|
|
@@ -319,8 +302,23 @@ class Figure:
|
|
|
319
302
|
for c in self._col_dict:
|
|
320
303
|
r,g,b=self._col_dict[c]
|
|
321
304
|
lines0.insert(1,f"\\definecolor{{{c}}}{{rgb}}{{{r:.3f}, {g:.3f}, {b:.3f}}}")
|
|
305
|
+
preambule = ""
|
|
306
|
+
stdalone = TikzConfig.STANDALONE if standalone is None else standalone
|
|
307
|
+
if stdalone:
|
|
308
|
+
if png:
|
|
309
|
+
preambule += "\\documentclass[tikz,border=2pt,convert={density=300,outext=.png}]{standalone}\n"
|
|
310
|
+
else:
|
|
311
|
+
preambule += "\\documentclass[tikz,border=2pt]{standalone}\n"
|
|
312
|
+
self._check_required_packages()
|
|
313
|
+
preambule += "\n".join(self._required_packages.keys()) + "\n"
|
|
314
|
+
preambule += "\\begin{document}\n"
|
|
315
|
+
if print_requirements and not stdalone:
|
|
316
|
+
self._check_required_packages()
|
|
317
|
+
print("Required packages:")
|
|
318
|
+
for p in self._required_packages.keys():
|
|
319
|
+
print(p)
|
|
322
320
|
fin = ""
|
|
323
|
-
if
|
|
321
|
+
if stdalone:
|
|
324
322
|
fin += "\\end{document}"
|
|
325
323
|
for k in self._lims.keys():
|
|
326
324
|
for j in self._lims[k]:
|
|
@@ -329,8 +327,8 @@ class Figure:
|
|
|
329
327
|
output = preambule + "\n" + "\n".join(lines) + "\n" + fin
|
|
330
328
|
return output
|
|
331
329
|
|
|
332
|
-
def _save(self, filename):
|
|
333
|
-
content = self._to_tex(filename)
|
|
330
|
+
def _save(self, filename, standalone=None, print_requirements=False):
|
|
331
|
+
content = self._to_tex(filename, png=False, standalone=standalone, print_requirements=print_requirements)
|
|
334
332
|
if not TikzConfig.SAVE_DATAPOINTS or (TikzConfig.SAVE_DATAPOINTS and not TikzConfig.UPDATE_DATA_ONLY):
|
|
335
333
|
with open(filename, "w", encoding="utf-8") as f:
|
|
336
334
|
f.write(content)
|
|
@@ -370,3 +368,29 @@ class Figure:
|
|
|
370
368
|
|
|
371
369
|
def tight_layout(self):
|
|
372
370
|
pass
|
|
371
|
+
|
|
372
|
+
def _add_required_package(self, package):
|
|
373
|
+
if package not in self._required_packages:
|
|
374
|
+
if package.startswith("\\usepackage"):
|
|
375
|
+
self._required_packages[package] = 2
|
|
376
|
+
elif package.startswith("\\pgfplotsset"):
|
|
377
|
+
self._required_packages[package] = 3
|
|
378
|
+
elif package.startswith("\\usetikzlibrary"):
|
|
379
|
+
self._required_packages[package] = 4
|
|
380
|
+
elif package.startswith("\\usepgfplotslibrary"):
|
|
381
|
+
self._required_packages[package] = 5
|
|
382
|
+
else:
|
|
383
|
+
self._required_packages[package] = 6
|
|
384
|
+
|
|
385
|
+
def _check_required_packages(self):
|
|
386
|
+
single = self._nrows * self._ncols == 1
|
|
387
|
+
self._required_packages["\\usepackage{tikz}"] = 0
|
|
388
|
+
self._required_packages["\\usepackage{pgfplots}"] = 1
|
|
389
|
+
if TikzConfig.USE_GROUPPLOTS and not single:
|
|
390
|
+
self._required_packages["\\usepgfplotslibrary{groupplots}"] = 5
|
|
391
|
+
self._required_packages[f"\\pgfplotsset{{compat={TikzConfig.TIKZ_COMPAT}}}"] = 3
|
|
392
|
+
if TikzConfig.USE_XCOLOR:
|
|
393
|
+
self._required_packages["\\usepackage{xcolor}"] = 2
|
|
394
|
+
if self._spies:
|
|
395
|
+
self._required_packages["\\usetikzlibrary{spy}"] = 4
|
|
396
|
+
self._required_packages = dict(sorted(self._required_packages.items(), key=lambda item: item[1]))
|
|
@@ -58,8 +58,8 @@ class Figure:
|
|
|
58
58
|
def _shared_ranges(self) -> None: ...
|
|
59
59
|
def _add_spy(self, zoom: float, size: float, **kwargs) -> int: ...
|
|
60
60
|
def _reduce_points(self) -> None: ...
|
|
61
|
-
def _to_tex(self, filename: str, png: Optional[bool]=False) -> str: ...
|
|
62
|
-
def _save(self, filename: str) -> None: ...
|
|
61
|
+
def _to_tex(self, filename: str, png: Optional[bool]=False, standalone: None | bool=None, print_requirements: bool=False) -> str: ...
|
|
62
|
+
def _save(self, filename: str, standalone: None | bool=None, print_requirements: bool=False) -> None: ...
|
|
63
63
|
def _save_image(self, filename: str) -> None: ...
|
|
64
64
|
def _get_width(self) -> float | None: ...
|
|
65
65
|
def _get_height(self) -> float | None: ...
|
|
@@ -80,3 +80,5 @@ class Figure:
|
|
|
80
80
|
Placeholder; spacings are set in TikzConfig.
|
|
81
81
|
"""
|
|
82
82
|
...
|
|
83
|
+
def _add_required_package(self, package: str) -> None: ...
|
|
84
|
+
def _check_required_packages(self) -> None: ...
|
|
@@ -258,7 +258,7 @@ def yscale( *args, **kwargs):
|
|
|
258
258
|
assert _current_axes
|
|
259
259
|
_current_axes.set_yscale(*args, **kwargs)
|
|
260
260
|
|
|
261
|
-
def savefig(filename):
|
|
261
|
+
def savefig(filename, standalone=None, print_requirements=False):
|
|
262
262
|
_im = False
|
|
263
263
|
if filename.endswith(".png"):
|
|
264
264
|
if not TikzConfig.STANDALONE:
|
|
@@ -273,11 +273,11 @@ def savefig(filename):
|
|
|
273
273
|
if _im:
|
|
274
274
|
_current_figure._save_image(filename)
|
|
275
275
|
else:
|
|
276
|
-
_current_figure._save(filename)
|
|
276
|
+
_current_figure._save(filename, standalone=standalone, print_requirements=print_requirements)
|
|
277
277
|
|
|
278
|
-
def show():
|
|
278
|
+
def show(standalone=None, print_requirements=False):
|
|
279
279
|
assert _current_figure
|
|
280
|
-
_current_figure._save(f"{str(main_name()[1]).removesuffix('.py')}_{TikzConfig.SHOW_SAVENAME}{next_show_num()}.tex")
|
|
280
|
+
_current_figure._save(f"{str(main_name()[1]).removesuffix('.py')}_{TikzConfig.SHOW_SAVENAME}{next_show_num()}.tex", standalone=standalone, print_requirements=print_requirements)
|
|
281
281
|
clf()
|
|
282
282
|
|
|
283
283
|
def clf():
|
|
@@ -881,18 +881,36 @@ def minorticks_num(self, num: int) -> None:
|
|
|
881
881
|
Number of minor ticks between major ticks.
|
|
882
882
|
"""
|
|
883
883
|
|
|
884
|
-
def savefig(filename: str) -> None:
|
|
884
|
+
def savefig(filename: str, standalone: None | bool = None, print_requirements: bool = False) -> None:
|
|
885
885
|
"""
|
|
886
886
|
Save figure to .tex/.tikz file.
|
|
887
887
|
|
|
888
888
|
If no suitable extension is provided, '.tex' is appended. If using .png extension, the code generated will compile to a .png image.
|
|
889
|
+
|
|
890
|
+
Parameters
|
|
891
|
+
----------
|
|
892
|
+
filename: str
|
|
893
|
+
Name of the file to save the figure to. If no suitable extension is provided, '.tex' is appended. If using .png extension, the code generated will compile to a .png image.
|
|
894
|
+
|
|
895
|
+
standalone: bool, optional
|
|
896
|
+
If True, the generated .tex file will be a standalone document. If False, it will be a fragment that can be included in another document. If None (default), the behavior is determined by the global setting `TikzConfig.STANDALONE`.
|
|
897
|
+
|
|
898
|
+
print_requirements: bool, optional
|
|
899
|
+
If True, the required LaTeX packages will be printed to the console. Inhibited for standalone.
|
|
889
900
|
"""
|
|
890
901
|
...
|
|
891
902
|
|
|
892
|
-
def show() -> None:
|
|
903
|
+
def show(standalone: None | bool = None, print_requirements: bool = False) -> None:
|
|
893
904
|
"""
|
|
894
905
|
Save figure to autogenerated filename and clear it.
|
|
895
|
-
|
|
906
|
+
|
|
907
|
+
Parameters
|
|
908
|
+
----------
|
|
909
|
+
standalone: bool, optional
|
|
910
|
+
If True, the generated .tex file will be a standalone document. If False, it will be a fragment that can be included in another document. If None (default), the behavior is determined by the global setting `TikzConfig.STANDALONE`.
|
|
911
|
+
|
|
912
|
+
print_requirements: bool, optional
|
|
913
|
+
If True, the required LaTeX packages will be printed to the console. Inhibited for standalone."""
|
|
896
914
|
...
|
|
897
915
|
|
|
898
916
|
def clf() -> None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tikzplot42
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.7
|
|
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
|
|
@@ -717,13 +717,15 @@ Alternativley, download this package and install using: `pip install [path]`, wh
|
|
|
717
717
|
Instead of using `import matplotlib.pyplot (as plt)`, use `import tikzplot.plots (as plt)`.
|
|
718
718
|
|
|
719
719
|
## LaTeX requirements
|
|
720
|
+
All required packages are automatically detected and can be printed at save using kwarg `print_requirements=True` (for standalone files, preambule is automatically added).
|
|
720
721
|
- `\usepackage{tikz}`,
|
|
721
722
|
- `\usepackage{pgfplots}`,
|
|
722
723
|
- `\pgfplotsset{compat=1.18}` (may be lower, but compilation is not guaranteed),
|
|
723
724
|
- `\usepgfplotslibrary{fillbetween}` (if you use fill-between plots),
|
|
724
725
|
- `\usepgfplotslibrary{groupplots}` (recommended for best results, enabled by default, may be avoided by setting TikzConfig USE_GROUPPLOTS=False),
|
|
725
726
|
- `\usepackage{xcolor}` (recommended for best colors, works without but needs change of TikzConfig USE_XCOLOR=False),
|
|
726
|
-
- `\usepgfplotslibrary{polar}` required for polar axis
|
|
727
|
+
- `\usepgfplotslibrary{polar}` required for polar axis,
|
|
728
|
+
- `\usetikzlibrary{patterns.meta}` for hatch patterns (available for fill_between, hist and axvspan/axhspan).
|
|
727
729
|
|
|
728
730
|
Export using `plt.savefig("example_graph.tex")` (recommended) or `plt.show()`.
|
|
729
731
|
Then use the generated file as `\input{example_graph.tex}`.
|
|
@@ -768,7 +770,7 @@ If axes and plot have different name for command with same effect, both are impl
|
|
|
768
770
|
There is a limited support for built-in styles (e.g. `plt.style.use("default")`), you may also define your own style using `plt.style.set_profile()`. Currently supported features are: color cycle (hex colors sequence), line width (in pt), grid (with matplotlib kwargs), background (latex style key=value), additional settings (raw latex code for optional arguments to axis: key=value).
|
|
769
771
|
|
|
770
772
|
#### Supported common **kwargs
|
|
771
|
-
- `color/c
|
|
773
|
+
- `color/c`,
|
|
772
774
|
- `linestyle/ls`,
|
|
773
775
|
- `linewidth/ls`,
|
|
774
776
|
- `fmt`,
|
|
@@ -790,6 +792,7 @@ For plot configurations (default sizes, paddings, etc.), use `from tikzplot impo
|
|
|
790
792
|
Currently supported parameters are listed with their default values in `src/tikzplot/config.py`.
|
|
791
793
|
|
|
792
794
|
## More features coming soon...
|
|
795
|
+
- bar plots,
|
|
793
796
|
- more developed styles,
|
|
794
797
|
- improved 3D plots (currently only basic support: plot, errorbar, fill_between, scatter, plot_wireframe, plot_surface),
|
|
795
798
|
- ...
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|