Python interface to generate (readable) Tikz figures.
Create and activate python environment, then install tikzpics with
pip install tikzpics
Generate two nodes connected by an arrow, see Figure 1.
from tikzpics import TikzFigure
fig = TikzFigure()
n1 = fig.add_node(0, 0, shape="circle", color="white", fill="blue", content="Tikz")
n2 = fig.add_node(2, 0, shape="circle", color="white", fill="red", content="Pics")
fig.draw([n1, n2], options=["->", "line width=2"], color="gray")
fig.show()You can also save the figure as a .tikz file or print the LaTeX code:
print(fig)% --------------------------------------------- %
% Tikzfigure generated by tikzpics v0.1.3 %
% https://github.com/max-models/tikzpics %
% --------------------------------------------- %
\begin{tikzpicture}
\node[shape=circle, color=white, fill=blue] (node0) at (0, 0) {Tikz};
\node[shape=circle, color=white, fill=red] (node1) at (2, 0) {Pics};
\draw[->, line width=2, color=gray] (node0) to (node1);
\end{tikzpicture}
Note that to visualize the plots in a popup or in jupyterlab, install
with pip install "tikzpics[vis]"
tikzpics includes IPython magic commands for compiling TikZ figures directly in Jupyter notebooks!
Load the extension:
%load_ext tikzpics.ipythonThen use the %%tikz cell magic:
%%tikz
\begin{tikzpicture}
\draw[thick, blue] (0,0) circle (2cm);
\node at (0,0) {Hello TikZ!};
\end{tikzpicture}
See tutorials for more examples!
