tikzplot42 0.5.13__tar.gz → 0.6.0__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.5.13 → tikzplot42-0.6.0}/PKG-INFO +2 -1
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/README.md +1 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/pyproject.toml +1 -1
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/axes.py +46 -24
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/axes.pyi +3 -3
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/elements.py +6 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/figure.py +9 -7
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/figure.pyi +3 -3
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot42.egg-info/PKG-INFO +2 -1
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot42.egg-info/SOURCES.txt +1 -0
- tikzplot42-0.6.0/tests/test28.py +34 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/LICENSE +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/setup.cfg +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/__init__.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/__init__.pyi +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/axes3d.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/axes3d.pyi +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/border_finder.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/colorbar.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/colorbar.pyi +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/colors.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/config.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/config.pyi +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/elements.pyi +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/latex_special.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/pie.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/plots.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/plots.pyi +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/py.typed +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/state.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/styles.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/styles.pyi +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot/texts.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot42.egg-info/dependency_links.txt +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot42.egg-info/requires.txt +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/src/tikzplot42.egg-info/top_level.txt +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test1.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test10.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test11.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test12.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test13.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test14.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test15.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test16.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test17.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test18.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test19.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test2.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test20.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test21.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test22.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test23.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test24.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test25.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test26.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test27.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test3.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test4.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test5.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test6.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test7.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test8.py +0 -0
- {tikzplot42-0.5.13 → tikzplot42-0.6.0}/tests/test9.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tikzplot42
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
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
|
|
@@ -735,6 +735,7 @@ All required packages are automatically detected and can be printed at save usin
|
|
|
735
735
|
- `\usepgfplotslibrary{groupplots}` (recommended for best results, enabled by default, may be avoided by setting TikzConfig USE_GROUPPLOTS=False),
|
|
736
736
|
- `\usepackage{xcolor}` (recommended for best colors, works without but needs change of TikzConfig USE_XCOLOR=False),
|
|
737
737
|
- `\usepgfplotslibrary{polar}` required for polar axis,
|
|
738
|
+
- `\usepgfplotslibrary{smithchart}` required for Smith chart axis,
|
|
738
739
|
- `\usetikzlibrary{patterns.meta}` for hatch patterns (available for fill_between, hist and axvspan/axhspan).
|
|
739
740
|
|
|
740
741
|
Export using `plt.savefig("example_graph.tex")` (recommended) or `plt.show()`.
|
|
@@ -35,6 +35,7 @@ All required packages are automatically detected and can be printed at save usin
|
|
|
35
35
|
- `\usepgfplotslibrary{groupplots}` (recommended for best results, enabled by default, may be avoided by setting TikzConfig USE_GROUPPLOTS=False),
|
|
36
36
|
- `\usepackage{xcolor}` (recommended for best colors, works without but needs change of TikzConfig USE_XCOLOR=False),
|
|
37
37
|
- `\usepgfplotslibrary{polar}` required for polar axis,
|
|
38
|
+
- `\usepgfplotslibrary{smithchart}` required for Smith chart axis,
|
|
38
39
|
- `\usetikzlibrary{patterns.meta}` for hatch patterns (available for fill_between, hist and axvspan/axhspan).
|
|
39
40
|
|
|
40
41
|
Export using `plt.savefig("example_graph.tex")` (recommended) or `plt.show()`.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tikzplot42"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.0"
|
|
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" }
|
|
@@ -174,7 +174,7 @@ class BaseAxes:
|
|
|
174
174
|
if cb is not None:
|
|
175
175
|
if self._cmap_bar.get(self._get_overlay(), None) is not None and self._cmap_bar[self._get_overlay()] != cb:
|
|
176
176
|
self._get_free_overlay(cb=cb)
|
|
177
|
-
if isinstance(self, Axes) and self.
|
|
177
|
+
if isinstance(self, Axes) and self._projection == "polar":
|
|
178
178
|
x = _np.rad2deg(x)
|
|
179
179
|
e = Graph(self, (x, y), settings, xerr=xerr, yerr=yerr, **style)
|
|
180
180
|
if overlay is None:
|
|
@@ -819,12 +819,14 @@ class BaseAxes:
|
|
|
819
819
|
for k in kws - {"label"}:
|
|
820
820
|
if k in kwargs:
|
|
821
821
|
st[k] = kwargs.pop(k)
|
|
822
|
+
output = []
|
|
822
823
|
for i in range(len(ys)):
|
|
823
824
|
if i == 0 and "label" in kwargs:
|
|
824
|
-
|
|
825
|
+
output.append(self._plot([xmins[i], xmaxs[i]], [ys[i]]*2, None, None, None, c=colorss[i], ls=lss[i], label=kwargs["label"], **st))
|
|
825
826
|
else:
|
|
826
|
-
|
|
827
|
-
|
|
827
|
+
output.append(self._plot([xmins[i], xmaxs[i]], [ys[i]]*2, None, None, None, c=colorss[i], ls=lss[i], **st))
|
|
828
|
+
return output
|
|
829
|
+
|
|
828
830
|
def vlines(self, x, ymin, ymax, colors="k", linestyles="solid", **kwargs):
|
|
829
831
|
kws = {"label", "color", "c", "linewidth", "lw", "linestyle", "ls", "alpha"}
|
|
830
832
|
kwargs = self._check_kwargs("vlines", kws, **kwargs)
|
|
@@ -847,11 +849,13 @@ class BaseAxes:
|
|
|
847
849
|
for k in kws - {"label"}:
|
|
848
850
|
if k in kwargs:
|
|
849
851
|
st[k] = kwargs.pop(k)
|
|
852
|
+
output = []
|
|
850
853
|
for i in range(len(xs)):
|
|
851
854
|
if i == 0 and "label" in kwargs:
|
|
852
|
-
self._plot([xs[i]]*2, [ymins[i], ymaxs[i]], None, None, None, c=colorss[i], ls=lss[i], label=kwargs["label"], **st)
|
|
855
|
+
output.append(self._plot([xs[i]]*2, [ymins[i], ymaxs[i]], None, None, None, c=colorss[i], ls=lss[i], label=kwargs["label"], **st))
|
|
853
856
|
else:
|
|
854
|
-
self._plot([xs[i]]*2, [ymins[i], ymaxs[i]], None, None, None, c=colorss[i], ls=lss[i], **st)
|
|
857
|
+
output.append(self._plot([xs[i]]*2, [ymins[i], ymaxs[i]], None, None, None, c=colorss[i], ls=lss[i], **st))
|
|
858
|
+
return output
|
|
855
859
|
|
|
856
860
|
def hist(self, x, bins=10, density=False,**kwargs):
|
|
857
861
|
kws = {"alpha", "color", "c", "label", "facecolor", "fc", "edgecolor", "ec", "orientation", "rwidth", "cumulative", "range", "histtype", "weights", "cumulative", "align", "stacked", "fill", "hatch", "hatch_color", "hatch_linewidth", "hatch_distance"}
|
|
@@ -2447,7 +2451,7 @@ class BaseAxes:
|
|
|
2447
2451
|
self._axis_options["ymin"], self._axis_options["ymax"] = ymax, ymin
|
|
2448
2452
|
|
|
2449
2453
|
class Axes(BaseAxes):
|
|
2450
|
-
def __init__(self, nrows, ncols, index, fig,
|
|
2454
|
+
def __init__(self, nrows, ncols, index, fig, projection):
|
|
2451
2455
|
super().__init__()
|
|
2452
2456
|
self._left = False
|
|
2453
2457
|
self._neigh = None
|
|
@@ -2470,7 +2474,7 @@ class Axes(BaseAxes):
|
|
|
2470
2474
|
self._colorbar: dict[int, None|str] = {0: None}
|
|
2471
2475
|
self._cbar_v = False
|
|
2472
2476
|
self._cbar_h = False
|
|
2473
|
-
self.
|
|
2477
|
+
self._projection = projection
|
|
2474
2478
|
|
|
2475
2479
|
self._ext_xmin = False
|
|
2476
2480
|
self._ext_xmax = False
|
|
@@ -2865,8 +2869,8 @@ class Axes(BaseAxes):
|
|
|
2865
2869
|
self._xticks = False
|
|
2866
2870
|
|
|
2867
2871
|
def twinx(self):
|
|
2868
|
-
if self.
|
|
2869
|
-
raise Exception("Cannot create twinx() on
|
|
2872
|
+
if self._projection in ["polar", "smith"]:
|
|
2873
|
+
raise Exception("Cannot create twinx() on non-normal projection.")
|
|
2870
2874
|
self._secondary_y = Secondary(self)
|
|
2871
2875
|
self._ext_xmin = self._ext_xmax = True
|
|
2872
2876
|
self.tick_params(axis="y", right=False)
|
|
@@ -3123,16 +3127,20 @@ class Axes(BaseAxes):
|
|
|
3123
3127
|
self._overlay_special[k].update({key: val}) """
|
|
3124
3128
|
lines = []
|
|
3125
3129
|
lines2 = []
|
|
3126
|
-
if self.
|
|
3130
|
+
if self._projection == "polar":
|
|
3127
3131
|
self._fig._add_required_package("\\usepgfplotslibrary{polar}")
|
|
3132
|
+
elif self._projection == "smith":
|
|
3133
|
+
self._fig._add_required_package("\\usepgfplotslibrary{smithchart}")
|
|
3128
3134
|
main_ax, aux_ax, alias, adds = self._axis_option_string()
|
|
3129
3135
|
contents = self._content_tex(filename)
|
|
3130
3136
|
if self._extend is not None:
|
|
3131
3137
|
lines.append(f"\\nextgroupplot[alias={alias}, width={self._extend[0]}cm, height={self._extend[1]}cm, hide axis]")
|
|
3132
3138
|
for i in self._elements.keys():
|
|
3133
3139
|
spec = ",\n".join([self._parse_entry(k, v) for k, v in self._overlay_special.get(i, {}).items()]) + ",\n" if i in self._overlay_special else ""
|
|
3134
|
-
if self.
|
|
3140
|
+
if self._projection == "polar":
|
|
3135
3141
|
lines2.append("\\begin{polaraxis}["+ f"\n at={{({alias}.south west)}},")
|
|
3142
|
+
elif self._projection == "smith":
|
|
3143
|
+
lines2.append("\\begin{smithchart}["+ f"\n at={{({alias}.south west)}},")
|
|
3136
3144
|
else:
|
|
3137
3145
|
lines2.append("\\begin{axis}[" + f"\n at={{({alias}.south west)}},")
|
|
3138
3146
|
if TikzConfig.SCALE_ONLY_AXIS:
|
|
@@ -3142,8 +3150,10 @@ class Axes(BaseAxes):
|
|
|
3142
3150
|
else:
|
|
3143
3151
|
lines2.append(f"{aux_ax}{spec}\n]")
|
|
3144
3152
|
lines2.append(contents[i])
|
|
3145
|
-
if self.
|
|
3153
|
+
if self._projection == "polar":
|
|
3146
3154
|
lines2.append("\\end{polaraxis}")
|
|
3155
|
+
elif self._projection == "smith":
|
|
3156
|
+
lines2.append("\\end{smithchart}")
|
|
3147
3157
|
else:
|
|
3148
3158
|
lines2.append("\\end{axis}")
|
|
3149
3159
|
if self._secondary_y is not None:
|
|
@@ -3167,32 +3177,42 @@ class Axes(BaseAxes):
|
|
|
3167
3177
|
if add_l:
|
|
3168
3178
|
lines2.append(add_l)
|
|
3169
3179
|
lines2.append("\\end{axis}")
|
|
3170
|
-
elif self.
|
|
3171
|
-
lines.append(f"\\nextgroupplot[alias={
|
|
3180
|
+
elif self._projection in ["polar", "smith"] and TikzConfig.USE_GROUPPLOTS and not single:
|
|
3181
|
+
lines.append(f"\\nextgroupplot[alias={alias}, width={self._width}, height={self._height}, hide axis]")
|
|
3172
3182
|
for i in self._elements.keys():
|
|
3173
3183
|
spec = ",\n".join([self._parse_entry(k, v) for k, v in self._overlay_special.get(i, {}).items()]) + ",\n" if i in self._overlay_special else ""
|
|
3174
3184
|
if i in adds:
|
|
3175
3185
|
spec += adds[i]
|
|
3176
|
-
|
|
3186
|
+
if self._projection == "polar":
|
|
3187
|
+
lines2.append("\\begin{polaraxis}["+ f"\n at={{({alias}.south west)}},")
|
|
3188
|
+
elif self._projection == "smith":
|
|
3189
|
+
lines2.append("\\begin{smithchart}["+ f"\n at={{({alias}.south west)}},")
|
|
3177
3190
|
if TikzConfig.SCALE_ONLY_AXIS:
|
|
3178
|
-
lines2.append("scale only axis")
|
|
3191
|
+
lines2.append("scale only axis,")
|
|
3179
3192
|
if i == self._get_overlay():
|
|
3180
3193
|
lines2.append(f"{main_ax}{spec}\n]")
|
|
3181
3194
|
else:
|
|
3182
3195
|
lines2.append(f"{aux_ax}{spec}\n]")
|
|
3183
3196
|
lines2.append(contents[i])
|
|
3184
|
-
|
|
3197
|
+
if self._projection == "polar":
|
|
3198
|
+
lines2.append("\\end{polaraxis}")
|
|
3199
|
+
elif self._projection == "smith":
|
|
3200
|
+
lines2.append("\\end{smithchart}")
|
|
3185
3201
|
else:
|
|
3186
|
-
if
|
|
3187
|
-
lines.append("\\nextgroupplot[")
|
|
3188
|
-
if self._polar:
|
|
3202
|
+
if self._projection == "polar":
|
|
3189
3203
|
lines.append("\\begin{polaraxis}[")
|
|
3190
3204
|
if TikzConfig.SCALE_ONLY_AXIS:
|
|
3191
|
-
lines.append("scale only axis")
|
|
3205
|
+
lines.append("scale only axis,")
|
|
3206
|
+
elif self._projection == "smith":
|
|
3207
|
+
lines.append("\\begin{smithchart}[")
|
|
3208
|
+
if TikzConfig.SCALE_ONLY_AXIS:
|
|
3209
|
+
lines.append("scale only axis,")
|
|
3210
|
+
elif TikzConfig.USE_GROUPPLOTS and not single:
|
|
3211
|
+
lines.append("\\nextgroupplot[")
|
|
3192
3212
|
elif not TikzConfig.USE_GROUPPLOTS or (TikzConfig.USE_GROUPPLOTS and single):
|
|
3193
3213
|
lines.append("\\begin{axis}[")
|
|
3194
3214
|
if TikzConfig.SCALE_ONLY_AXIS:
|
|
3195
|
-
lines.append("scale only axis")
|
|
3215
|
+
lines.append("scale only axis,")
|
|
3196
3216
|
if self._get_overlay() == 0:
|
|
3197
3217
|
spec = ",\n".join([self._parse_entry(k, v) for k, v in self._overlay_special.get(0, {}).items()]) + ",\n" if 0 in self._overlay_special else ""
|
|
3198
3218
|
if 0 in adds:
|
|
@@ -3227,8 +3247,10 @@ class Axes(BaseAxes):
|
|
|
3227
3247
|
lines2.append(f"{aux_ax}{spec}at={{({alias}.south west)}}\n]")
|
|
3228
3248
|
lines2.append(contents[i])
|
|
3229
3249
|
lines2.append("\\end{axis}")
|
|
3230
|
-
if self.
|
|
3250
|
+
if self._projection == "polar":
|
|
3231
3251
|
lines.append("\\end{polaraxis}")
|
|
3252
|
+
elif self._projection == "smith":
|
|
3253
|
+
lines.append("\\end{smithchart}")
|
|
3232
3254
|
elif not TikzConfig.USE_GROUPPLOTS or (TikzConfig.USE_GROUPPLOTS and single):
|
|
3233
3255
|
lines.append("\\end{axis}")
|
|
3234
3256
|
if self._secondary_y is not None:
|
|
@@ -404,7 +404,7 @@ class BaseAxes:
|
|
|
404
404
|
colors: Union[str, Sequence[str]] = "k",
|
|
405
405
|
linestyles: Union[str, Sequence[str]] = "solid",
|
|
406
406
|
label: Optional[str] = None, color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., linewidth: Optional[float] = ..., lw: Optional[float] = ..., linestyle: Optional[LineStyle] = ..., ls: Optional[LineStyle] = ..., alpha: float = 1.0
|
|
407
|
-
) ->
|
|
407
|
+
) -> list[Graph]:
|
|
408
408
|
"""
|
|
409
409
|
Draw horizontal lines to the selected axis.
|
|
410
410
|
"""
|
|
@@ -417,7 +417,7 @@ class BaseAxes:
|
|
|
417
417
|
colors: Union[str, Sequence[str]] = "k",
|
|
418
418
|
linestyles: Union[str, Sequence[str]] = "solid",
|
|
419
419
|
label: Optional[str] = None, color: Optional[ColorLike] = ..., c: Optional[ColorLike] = ..., linewidth: Optional[float] = ..., lw: Optional[float] = ..., linestyle: Optional[LineStyle] = ..., ls: Optional[LineStyle] = ..., alpha: float = 1.0
|
|
420
|
-
) ->
|
|
420
|
+
) -> list[Graph]:
|
|
421
421
|
"""
|
|
422
422
|
Draw vertical lines to the selected axis.
|
|
423
423
|
"""
|
|
@@ -1949,7 +1949,7 @@ class BaseAxes:
|
|
|
1949
1949
|
def _not_hidable(self) -> None: ...
|
|
1950
1950
|
|
|
1951
1951
|
class Axes(BaseAxes):
|
|
1952
|
-
def __init__(self, nrows: int, ncols: int, index: int, fig: Any,
|
|
1952
|
+
def __init__(self, nrows: int, ncols: int, index: int, fig: Any, projection: Literal["normal", "polar", "smith"] = "normal") -> None: ...
|
|
1953
1953
|
|
|
1954
1954
|
def contourf(self, *args: Any, levels: Optional[Sequence[float]] = None, cmap: Optional[str] = None, colors: Optional[Sequence[ColorLike]] = None, vmin: Optional[float] = None, vmax: Optional[float] = None, alpha: float = 1.0) -> Graph:
|
|
1955
1955
|
"""
|
|
@@ -648,6 +648,10 @@ class Graph(BaseGraph):
|
|
|
648
648
|
elif isinstance(coordinates, tuple):
|
|
649
649
|
self._classic = True
|
|
650
650
|
x,y=coordinates
|
|
651
|
+
if isinstance(x, (list, tuple)):
|
|
652
|
+
x = [x]
|
|
653
|
+
if isinstance(y, (list, tuple)):
|
|
654
|
+
y = [y]
|
|
651
655
|
self._x = np.asarray(x)
|
|
652
656
|
self._y = np.asarray(y)
|
|
653
657
|
self._meta = self._settings.pop("meta", None)
|
|
@@ -756,6 +760,8 @@ class Graph(BaseGraph):
|
|
|
756
760
|
style = self._style_string().removesuffix(",\n")
|
|
757
761
|
|
|
758
762
|
def rel_coor(which, m, M, v):
|
|
763
|
+
if isinstance(m, str) or isinstance(M, str):
|
|
764
|
+
return m, M
|
|
759
765
|
if self._axes._axis_options.get(f"{which}mode") == "log":
|
|
760
766
|
r = M/m
|
|
761
767
|
lower = m * r**v[0]
|
|
@@ -62,9 +62,11 @@ class Figure:
|
|
|
62
62
|
|
|
63
63
|
if projection=="3d":
|
|
64
64
|
ax = Axes3(nrows, ncols, index, self)
|
|
65
|
+
elif projection is None or projection in ["normal", "polar", "smith"]:
|
|
66
|
+
proj: str = "polar" if polar else projection if projection is not None else "normal"
|
|
67
|
+
ax = Axes(nrows, ncols, index, self, proj)
|
|
65
68
|
else:
|
|
66
|
-
|
|
67
|
-
ax = Axes(nrows, ncols, index, self, pol)
|
|
69
|
+
raise ValueError(f"Invalid projection type: {projection}. If specified, must be 'normal', 'polar', 'smith', or '3d'.")
|
|
68
70
|
if self._nrows != 0 and self._ncols != 0 and (self._nrows != nrows or self._ncols != ncols):
|
|
69
71
|
raise ValueError("Cannot add subplot with different nrows/ncols than existing subplots")
|
|
70
72
|
self._nrows = nrows
|
|
@@ -214,25 +216,25 @@ class Figure:
|
|
|
214
216
|
new_name = get_free_name()
|
|
215
217
|
if position == "left":
|
|
216
218
|
insert_col(target_c)
|
|
217
|
-
new_axes = Axes(self._nrows, self._ncols, 0, self,
|
|
219
|
+
new_axes = Axes(self._nrows, self._ncols, 0, self, "normal")
|
|
218
220
|
self._mosaic[new_name] = dict(r=target_r, c=target_c, nr=target_nr, nc=1, ax=new_axes)
|
|
219
221
|
if self._wratios is not None:
|
|
220
222
|
self._wratios.insert(target_c, sum_w * relsize)
|
|
221
223
|
elif position == "right":
|
|
222
224
|
insert_col(target_c + target_nc)
|
|
223
|
-
new_axes = Axes(self._nrows, self._ncols, 0, self,
|
|
225
|
+
new_axes = Axes(self._nrows, self._ncols, 0, self, "normal")
|
|
224
226
|
self._mosaic[new_name] = dict(r=target_r, c=target_c + target_nc, nr=target_nr, nc=1, ax=new_axes)
|
|
225
227
|
if self._wratios is not None:
|
|
226
228
|
self._wratios.insert(target_c + target_nc, sum_w * relsize)
|
|
227
229
|
elif position == "above":
|
|
228
230
|
insert_row(target_r_top)
|
|
229
|
-
new_axes = Axes(self._nrows, self._ncols, 0, self,
|
|
231
|
+
new_axes = Axes(self._nrows, self._ncols, 0, self, "normal")
|
|
230
232
|
self._mosaic[new_name] = dict(r=target_r_top, c=target_c, nr=1, nc=target_nc, ax=new_axes)
|
|
231
233
|
if self._hratios is not None:
|
|
232
234
|
self._hratios.insert(target_r_top, sum_h * relsize)
|
|
233
235
|
else: # below
|
|
234
236
|
insert_row(target_r + 1)
|
|
235
|
-
new_axes = Axes(self._nrows, self._ncols, 0, self,
|
|
237
|
+
new_axes = Axes(self._nrows, self._ncols, 0, self, "normal")
|
|
236
238
|
self._mosaic[new_name] = dict(r=target_r + 1, c=target_c, nr=1, nc=target_nc, ax=new_axes)
|
|
237
239
|
if self._hratios is not None:
|
|
238
240
|
self._hratios.insert(target_r + 1, sum_h * relsize)
|
|
@@ -578,7 +580,7 @@ class Figure:
|
|
|
578
580
|
ncols = self._ncols
|
|
579
581
|
for i in range(1, 1 + nrows * ncols):
|
|
580
582
|
if i not in self._axes:
|
|
581
|
-
self._axes[i] = Axes(nrows, ncols, -i, self,
|
|
583
|
+
self._axes[i] = Axes(nrows, ncols, -i, self, "normal")
|
|
582
584
|
if TikzConfig.USE_GROUPPLOTS and not single:
|
|
583
585
|
if TikzConfig.SIMULATE_SIZES:
|
|
584
586
|
if _can_compile_tex():
|
|
@@ -30,7 +30,7 @@ class Figure:
|
|
|
30
30
|
*args,
|
|
31
31
|
sharex: Optional[ShareOptions] = None,
|
|
32
32
|
sharey: Optional[ShareOptions] = None,
|
|
33
|
-
projection: Optional[Literal["polar"]] = None,
|
|
33
|
+
projection: Optional[Literal["normal", "polar", "smith"]] = None,
|
|
34
34
|
polar: Optional[bool] = False,
|
|
35
35
|
) -> Axes:
|
|
36
36
|
...
|
|
@@ -45,8 +45,8 @@ class Figure:
|
|
|
45
45
|
sharex, sharey: bool or "row" or "col" or "all" or "none", optional
|
|
46
46
|
Share x or y axes with other subplots.
|
|
47
47
|
|
|
48
|
-
projection: None, "polar", "3d", optional
|
|
49
|
-
None results in normal 2D.
|
|
48
|
+
projection: None or "normal", "polar", "smith", "3d", optional
|
|
49
|
+
None results in normal 2D. For Smith projection, complex input should be provided as cartesian (x = z.real, y = z.imag).
|
|
50
50
|
|
|
51
51
|
polar: bool, optional
|
|
52
52
|
Use polar projection for axis.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tikzplot42
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
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
|
|
@@ -735,6 +735,7 @@ All required packages are automatically detected and can be printed at save usin
|
|
|
735
735
|
- `\usepgfplotslibrary{groupplots}` (recommended for best results, enabled by default, may be avoided by setting TikzConfig USE_GROUPPLOTS=False),
|
|
736
736
|
- `\usepackage{xcolor}` (recommended for best colors, works without but needs change of TikzConfig USE_XCOLOR=False),
|
|
737
737
|
- `\usepgfplotslibrary{polar}` required for polar axis,
|
|
738
|
+
- `\usepgfplotslibrary{smithchart}` required for Smith chart axis,
|
|
738
739
|
- `\usetikzlibrary{patterns.meta}` for hatch patterns (available for fill_between, hist and axvspan/axhspan).
|
|
739
740
|
|
|
740
741
|
Export using `plt.savefig("example_graph.tex")` (recommended) or `plt.show()`.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import tikzplot.plots as plt
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
# Sample data
|
|
5
|
+
x = np.linspace(0, 2 * np.pi, 100)
|
|
6
|
+
y = np.sin(x)
|
|
7
|
+
|
|
8
|
+
fig = plt.figure(figsize=(8, 8))
|
|
9
|
+
|
|
10
|
+
# 1. Normal (Rectilinear) Projection
|
|
11
|
+
ax1 = fig.add_subplot(2, 2, 1)
|
|
12
|
+
ax1.plot(x, y, color="tab:blue")
|
|
13
|
+
ax1.set_title("Normal Projection")
|
|
14
|
+
ax1.grid(True)
|
|
15
|
+
|
|
16
|
+
# 2. 3D Projection
|
|
17
|
+
ax2 = fig.add_subplot(2, 2, 2, projection="3d")
|
|
18
|
+
z = np.cos(x)
|
|
19
|
+
ax2.plot(x, y, z, color="tab:orange")
|
|
20
|
+
ax2.set_title("3D Projection")
|
|
21
|
+
|
|
22
|
+
# 3. Polar Projection
|
|
23
|
+
ax3 = fig.add_subplot(2, 2, 3, projection="polar")
|
|
24
|
+
ax3.plot(x, y, color="tab:green")
|
|
25
|
+
ax3.set_title("Polar Projection")
|
|
26
|
+
|
|
27
|
+
# 4. Smith Chart Projection (requires your custom package imported beforehand)
|
|
28
|
+
ax4 = fig.add_subplot(2, 2, 4, projection="smith")
|
|
29
|
+
# Dummy impedance data (S-parameters / reflection coefficient)
|
|
30
|
+
z_smith = 0.5 + 0.5j + 0.4 * np.exp(1j * x)
|
|
31
|
+
ax4.plot(z_smith.real, z_smith.imag, color="tab:red")
|
|
32
|
+
ax4.set_title("Smith Projection")
|
|
33
|
+
|
|
34
|
+
plt.savefig("figure.tex")
|
|
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
|
|
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
|