Skip to content

Commit 969984e

Browse files
committed
Add tikzfigure to dependencies
1 parent 92d7b2e commit 969984e

6 files changed

Lines changed: 27 additions & 118 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies = [
1818
"matplotlib",
1919
"pint",
2020
"plotly",
21-
"tikzpics>=0.1.1",
21+
"tikzfigure>=0.2.0",
2222
]
2323
[project.optional-dependencies]
2424
test = [

src/maxplotlib/canvas/canvas.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import matplotlib.patches as patches
66
import matplotlib.pyplot as plt
77
from plotly.subplots import make_subplots
8-
from tikzpics import TikzFigure
8+
from tikzfigure import TikzFigure
99

1010
from maxplotlib.backends.matplotlib.utils import (
1111
set_size,
@@ -415,8 +415,8 @@ def plot(
415415
)
416416
elif backend == "plotly":
417417
return self.plot_plotly(savefig=savefig)
418-
elif backend == "tikzpics":
419-
return self.plot_tikzpics(savefig=savefig)
418+
elif backend == "tikzfigure":
419+
return self.plot_tikzfigure(savefig=savefig)
420420
else:
421421
raise ValueError(f"Invalid backend: {backend}")
422422

@@ -438,8 +438,8 @@ def show(
438438
# self._matplotlib_fig.show()
439439
elif backend == "plotly":
440440
self.plot_plotly(savefig=False)
441-
elif backend == "tikzpics":
442-
fig = self.plot_tikzpics(savefig=False, verbose=verbose)
441+
elif backend == "tikzfigure":
442+
fig = self.plot_tikzfigure(savefig=False, verbose=verbose)
443443
fig.show()
444444
else:
445445
raise ValueError("Invalid backend")
@@ -507,20 +507,20 @@ def plot_matplotlib(
507507
self._matplotlib_axes = axes
508508
return fig, axes
509509

510-
def plot_tikzpics(
510+
def plot_tikzfigure(
511511
self,
512512
savefig: str | None = None,
513513
verbose: bool = False,
514514
) -> TikzFigure:
515515
if len(self.subplots) > 1:
516516
raise NotImplementedError(
517-
"Only one subplot is supported for tikzpics backend."
517+
"Only one subplot is supported for tikzfigure backend."
518518
)
519519
for (row, col), line_plot in self.subplots.items():
520520
if verbose:
521521
print(f"Plotting subplot at row {row}, col {col}")
522522
print(f"{line_plot = }")
523-
tikz_subplot = line_plot.plot_tikzpics(verbose=verbose)
523+
tikz_subplot = line_plot.plot_tikzfigure(verbose=verbose)
524524
return tikz_subplot
525525

526526
def plot_plotly(self, show=True, savefig=None, usetex=False):

src/maxplotlib/subfigure/line_plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33
import plotly.graph_objects as go
44
from mpl_toolkits.axes_grid1 import make_axes_locatable
5-
from tikzpics import TikzFigure
5+
from tikzfigure import TikzFigure
66

77

88
class Node:
@@ -221,7 +221,7 @@ def plot_matplotlib(
221221
if self.ymax is not None:
222222
ax.axis(ymax=self.ymax)
223223

224-
def plot_tikzpics(self, layers=None, verbose: bool = False) -> TikzFigure:
224+
def plot_tikzfigure(self, layers=None, verbose: bool = False) -> TikzFigure:
225225

226226
tikz_figure = TikzFigure()
227227
for layer_name, layer_lines in self.layered_line_data.items():

src/maxplotlib/utils/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from typing import Literal
22

3-
Backends = Literal["matplotlib", "plotly", "tikzpics"]
3+
Backends = Literal["matplotlib", "plotly", "tikzfigure"]

tutorials/tutorial_04.ipynb

Lines changed: 14 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,10 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 1,
13+
"execution_count": null,
1414
"id": "1",
1515
"metadata": {},
16-
"outputs": [
17-
{
18-
"data": {
19-
"text/plain": [
20-
"'\\nTutorial 4.\\n\\nAdd raw tikz code to the tikz subplot.\\n'"
21-
]
22-
},
23-
"execution_count": 1,
24-
"metadata": {},
25-
"output_type": "execute_result"
26-
}
27-
],
16+
"outputs": [],
2817
"source": [
2918
"\"\"\"\n",
3019
"Tutorial 4.\n",
@@ -35,7 +24,7 @@
3524
},
3625
{
3726
"cell_type": "code",
38-
"execution_count": 2,
27+
"execution_count": null,
3928
"id": "2",
4029
"metadata": {},
4130
"outputs": [],
@@ -45,7 +34,7 @@
4534
},
4635
{
4736
"cell_type": "code",
48-
"execution_count": 3,
37+
"execution_count": null,
4938
"id": "3",
5039
"metadata": {},
5140
"outputs": [],
@@ -56,23 +45,12 @@
5645
},
5746
{
5847
"cell_type": "code",
59-
"execution_count": 4,
48+
"execution_count": null,
6049
"id": "4",
6150
"metadata": {
6251
"lines_to_next_cell": 2
6352
},
64-
"outputs": [
65-
{
66-
"data": {
67-
"text/plain": [
68-
"<tikzpics.node.Node at 0x10ce7b5c0>"
69-
]
70-
},
71-
"execution_count": 4,
72-
"metadata": {},
73-
"output_type": "execute_result"
74-
}
75-
],
53+
"outputs": [],
7654
"source": [
7755
"# Add nodes\n",
7856
"tikz.add_node(0, 0, label=\"A\", shape=\"circle\", draw=\"black\", fill=\"blue\", layer=0)\n",
@@ -83,21 +61,10 @@
8361
},
8462
{
8563
"cell_type": "code",
86-
"execution_count": 5,
64+
"execution_count": null,
8765
"id": "5",
8866
"metadata": {},
89-
"outputs": [
90-
{
91-
"data": {
92-
"text/plain": [
93-
"<tikzpics.path.Path at 0x113e4d940>"
94-
]
95-
},
96-
"execution_count": 5,
97-
"metadata": {},
98-
"output_type": "execute_result"
99-
}
100-
],
67+
"outputs": [],
10168
"source": [
10269
"# Add a line between nodes\n",
10370
"tikz.draw(\n",
@@ -112,7 +79,7 @@
11279
},
11380
{
11481
"cell_type": "code",
115-
"execution_count": 6,
82+
"execution_count": null,
11683
"id": "6",
11784
"metadata": {},
11885
"outputs": [],
@@ -132,32 +99,21 @@
13299
},
133100
{
134101
"cell_type": "code",
135-
"execution_count": 8,
102+
"execution_count": null,
136103
"id": "7",
137104
"metadata": {},
138105
"outputs": [],
139106
"source": [
140-
"# TODO: Not implemented in tikzpics yet\n",
107+
"# TODO: Not implemented in tikzfigure yet\n",
141108
"# tikz.add_raw(raw_tikz)"
142109
]
143110
},
144111
{
145112
"cell_type": "code",
146-
"execution_count": 9,
113+
"execution_count": null,
147114
"id": "8",
148115
"metadata": {},
149-
"outputs": [
150-
{
151-
"data": {
152-
"text/plain": [
153-
"<tikzpics.node.Node at 0x113ecba80>"
154-
]
155-
},
156-
"execution_count": 9,
157-
"metadata": {},
158-
"output_type": "execute_result"
159-
}
160-
],
116+
"outputs": [],
161117
"source": [
162118
"tikz.add_node(0.5, 0.5, content=\"Cube\", layer=10)"
163119
]
@@ -167,54 +123,7 @@
167123
"execution_count": null,
168124
"id": "9",
169125
"metadata": {},
170-
"outputs": [
171-
{
172-
"name": "stdout",
173-
"output_type": "stream",
174-
"text": [
175-
"\n",
176-
"\n",
177-
"\n",
178-
"\n",
179-
"% --------------------------------------------- %\n",
180-
"% Tikzfigure generated by tikzpics v0.1.1 %\n",
181-
"% https://github.com/max-models/tikzpics %\n",
182-
"% --------------------------------------------- %\n",
183-
"\\begin{tikzpicture}\n",
184-
" \n",
185-
" % Define the layers library\n",
186-
" \\pgfdeclarelayer{0}\n",
187-
" \\pgfdeclarelayer{1}\n",
188-
" \\pgfdeclarelayer{10}\n",
189-
" \\pgfdeclarelayer{2}\n",
190-
" \\pgfsetlayers{0,1,10,2}\n",
191-
" \n",
192-
" % Layer 0\n",
193-
" \\begin{pgfonlayer}{0}\n",
194-
" \\node[shape=circle, draw=black, fill=blue] (A) at (0, 0) {};\n",
195-
" \\node[shape=circle, draw=black, fill=blue] (B) at (10, 0) {};\n",
196-
" \\node[shape=circle, draw=black, fill=blue] (C) at (10, 10) {};\n",
197-
" \\end{pgfonlayer}{0}\n",
198-
" \n",
199-
" % Layer 2\n",
200-
" \\begin{pgfonlayer}{2}\n",
201-
" \\node[shape=circle, draw=black, fill=blue] (D) at (0, 10) {};\n",
202-
" \\end{pgfonlayer}{2}\n",
203-
" \n",
204-
" % Layer 1\n",
205-
" \\begin{pgfonlayer}{1}\n",
206-
" \\draw[path actions=['draw', 'rounded corners'], fill=red, opacity=0.5] (A) to (B) to (C) to (D) -- cycle;\n",
207-
" \\end{pgfonlayer}{1}\n",
208-
" \n",
209-
" % Layer 10\n",
210-
" \\begin{pgfonlayer}{10}\n",
211-
" \\node (node4) at (0.5, 0.5) {Cube};\n",
212-
" \\end{pgfonlayer}{10}\n",
213-
"\\end{tikzpicture}\n",
214-
"\n"
215-
]
216-
}
217-
],
126+
"outputs": [],
218127
"source": [
219128
"# Generate the TikZ script\n",
220129
"script = tikz.generate_tikz()\n",

tutorials/tutorial_07_tikzpics.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"\n",
3535
"\n",
3636
"# TODO: Uncomment if pdflatex is installed\n",
37-
"# c.show(backend=\"tikzpics\")"
37+
"# c.show(backend=\"tikzfigure\")"
3838
]
3939
}
4040
],

0 commit comments

Comments
 (0)