diff --git a/pyproject.toml b/pyproject.toml index aa4ecb8..1fa3e94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "matplotlib", "pint", "plotly", - "tikzpics>=0.1.1", + "tikzfigure>=0.2.0", ] [project.optional-dependencies] test = [ diff --git a/src/maxplotlib/canvas/canvas.py b/src/maxplotlib/canvas/canvas.py index 962ab21..11d33e8 100644 --- a/src/maxplotlib/canvas/canvas.py +++ b/src/maxplotlib/canvas/canvas.py @@ -5,7 +5,7 @@ import matplotlib.patches as patches import matplotlib.pyplot as plt from plotly.subplots import make_subplots -from tikzpics import TikzFigure +from tikzfigure import TikzFigure from maxplotlib.backends.matplotlib.utils import ( set_size, @@ -415,8 +415,8 @@ def plot( ) elif backend == "plotly": return self.plot_plotly(savefig=savefig) - elif backend == "tikzpics": - return self.plot_tikzpics(savefig=savefig) + elif backend == "tikzfigure": + return self.plot_tikzfigure(savefig=savefig) else: raise ValueError(f"Invalid backend: {backend}") @@ -438,8 +438,8 @@ def show( # self._matplotlib_fig.show() elif backend == "plotly": self.plot_plotly(savefig=False) - elif backend == "tikzpics": - fig = self.plot_tikzpics(savefig=False, verbose=verbose) + elif backend == "tikzfigure": + fig = self.plot_tikzfigure(savefig=False, verbose=verbose) fig.show() else: raise ValueError("Invalid backend") @@ -507,20 +507,20 @@ def plot_matplotlib( self._matplotlib_axes = axes return fig, axes - def plot_tikzpics( + def plot_tikzfigure( self, savefig: str | None = None, verbose: bool = False, ) -> TikzFigure: if len(self.subplots) > 1: raise NotImplementedError( - "Only one subplot is supported for tikzpics backend." + "Only one subplot is supported for tikzfigure backend." ) for (row, col), line_plot in self.subplots.items(): if verbose: print(f"Plotting subplot at row {row}, col {col}") print(f"{line_plot = }") - tikz_subplot = line_plot.plot_tikzpics(verbose=verbose) + tikz_subplot = line_plot.plot_tikzfigure(verbose=verbose) return tikz_subplot def plot_plotly(self, show=True, savefig=None, usetex=False): diff --git a/src/maxplotlib/subfigure/line_plot.py b/src/maxplotlib/subfigure/line_plot.py index f314c3d..2b9872e 100644 --- a/src/maxplotlib/subfigure/line_plot.py +++ b/src/maxplotlib/subfigure/line_plot.py @@ -2,7 +2,7 @@ import numpy as np import plotly.graph_objects as go from mpl_toolkits.axes_grid1 import make_axes_locatable -from tikzpics import TikzFigure +from tikzfigure import TikzFigure class Node: @@ -221,7 +221,7 @@ def plot_matplotlib( if self.ymax is not None: ax.axis(ymax=self.ymax) - def plot_tikzpics(self, layers=None, verbose: bool = False) -> TikzFigure: + def plot_tikzfigure(self, layers=None, verbose: bool = False) -> TikzFigure: tikz_figure = TikzFigure() for layer_name, layer_lines in self.layered_line_data.items(): diff --git a/src/maxplotlib/utils/options.py b/src/maxplotlib/utils/options.py index 6666e4d..074514e 100644 --- a/src/maxplotlib/utils/options.py +++ b/src/maxplotlib/utils/options.py @@ -1,3 +1,3 @@ from typing import Literal -Backends = Literal["matplotlib", "plotly", "tikzpics"] +Backends = Literal["matplotlib", "plotly", "tikzfigure"] diff --git a/tutorials/tutorial_04.ipynb b/tutorials/tutorial_04.ipynb index ef2dc8b..abde34e 100644 --- a/tutorials/tutorial_04.ipynb +++ b/tutorials/tutorial_04.ipynb @@ -10,21 +10,10 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "1", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'\\nTutorial 4.\\n\\nAdd raw tikz code to the tikz subplot.\\n'" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "\"\"\"\n", "Tutorial 4.\n", @@ -35,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "2", "metadata": {}, "outputs": [], @@ -45,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "3", "metadata": {}, "outputs": [], @@ -56,23 +45,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "4", "metadata": { "lines_to_next_cell": 2 }, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Add nodes\n", "tikz.add_node(0, 0, label=\"A\", shape=\"circle\", draw=\"black\", fill=\"blue\", layer=0)\n", @@ -83,21 +61,10 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "5", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Add a line between nodes\n", "tikz.draw(\n", @@ -112,7 +79,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "6", "metadata": {}, "outputs": [], @@ -132,32 +99,21 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ - "# TODO: Not implemented in tikzpics yet\n", + "# TODO: Not implemented in tikzfigure yet\n", "# tikz.add_raw(raw_tikz)" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "8", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "tikz.add_node(0.5, 0.5, content=\"Cube\", layer=10)" ] @@ -167,54 +123,7 @@ "execution_count": null, "id": "9", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - "\n", - "\n", - "% --------------------------------------------- %\n", - "% Tikzfigure generated by tikzpics v0.1.1 %\n", - "% https://github.com/max-models/tikzpics %\n", - "% --------------------------------------------- %\n", - "\\begin{tikzpicture}\n", - " \n", - " % Define the layers library\n", - " \\pgfdeclarelayer{0}\n", - " \\pgfdeclarelayer{1}\n", - " \\pgfdeclarelayer{10}\n", - " \\pgfdeclarelayer{2}\n", - " \\pgfsetlayers{0,1,10,2}\n", - " \n", - " % Layer 0\n", - " \\begin{pgfonlayer}{0}\n", - " \\node[shape=circle, draw=black, fill=blue] (A) at (0, 0) {};\n", - " \\node[shape=circle, draw=black, fill=blue] (B) at (10, 0) {};\n", - " \\node[shape=circle, draw=black, fill=blue] (C) at (10, 10) {};\n", - " \\end{pgfonlayer}{0}\n", - " \n", - " % Layer 2\n", - " \\begin{pgfonlayer}{2}\n", - " \\node[shape=circle, draw=black, fill=blue] (D) at (0, 10) {};\n", - " \\end{pgfonlayer}{2}\n", - " \n", - " % Layer 1\n", - " \\begin{pgfonlayer}{1}\n", - " \\draw[path actions=['draw', 'rounded corners'], fill=red, opacity=0.5] (A) to (B) to (C) to (D) -- cycle;\n", - " \\end{pgfonlayer}{1}\n", - " \n", - " % Layer 10\n", - " \\begin{pgfonlayer}{10}\n", - " \\node (node4) at (0.5, 0.5) {Cube};\n", - " \\end{pgfonlayer}{10}\n", - "\\end{tikzpicture}\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "# Generate the TikZ script\n", "script = tikz.generate_tikz()\n", diff --git a/tutorials/tutorial_07_tikzpics.ipynb b/tutorials/tutorial_07_tikzpics.ipynb index d3bc587..4a9e42b 100644 --- a/tutorials/tutorial_07_tikzpics.ipynb +++ b/tutorials/tutorial_07_tikzpics.ipynb @@ -34,7 +34,7 @@ "\n", "\n", "# TODO: Uncomment if pdflatex is installed\n", - "# c.show(backend=\"tikzpics\")" + "# c.show(backend=\"tikzfigure\")" ] } ],