.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/low_level_tikz.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_low_level_tikz.py: Low-level Tikz commands ======================== Use more low-level features of Tikz for added flexibility. .. GENERATED FROM PYTHON SOURCE LINES 7-10 .. code-block:: Python import pykz .. GENERATED FROM PYTHON SOURCE LINES 11-12 Make sure to open a new figure, otherwise, you may keep adding to one created in a previous script. .. GENERATED FROM PYTHON SOURCE LINES 12-15 .. code-block:: Python pykz.figure() .. rst-class:: sphx-glr-script-out .. code-block:: none TikzPicture() .. GENERATED FROM PYTHON SOURCE LINES 16-19 You can define your own styles, like one would using ``tikzset``. These styles automatically get added to the tikz code, so you can refer to their names in any draw, fill, node, ... command that follows. .. GENERATED FROM PYTHON SOURCE LINES 19-31 .. code-block:: Python pykz.define_style("arrow", **{">": "stealth", "->": True}) pykz.line([(-1, 0), (1, 0)], arrow=True) pykz.line([(0, -1), (0, 1)], arrow=True) # Export your tex code as a standalone file pykz.save("low_level_tikz.tex", standalone=True) # You could also directly build the pdf pykz.io.export_pdf_from_file("low_level_tikz.tex") .. image-sg:: /gallery/images/sphx_glr_low_level_tikz_001.png :alt: low level tikz :srcset: /gallery/images/sphx_glr_low_level_tikz_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 'low_level_tikz.pdf' .. GENERATED FROM PYTHON SOURCE LINES 32-47 Alternatively, output it to png .. code-block:: python pykz.io.export_png_from_file("low_level_tikz.tex") Or, save the Tikz code to a temporary file, compile it, and open the pdf in the default viewer. This would be the equivalent to ``plt.show()`` .. code-block:: python pykz.preview() .. GENERATED FROM PYTHON SOURCE LINES 49-50 Alternatively, use the high-level functions .. GENERATED FROM PYTHON SOURCE LINES 50-61 .. code-block:: Python fig = pykz.figure() fig.set_option(">", "stealth") pykz.arrow([(-1, 0), (1, 0)]) pykz.arrow([(0, -1), (0, 1)]) # Export your tex code as a standalone file pykz.save("low_level_tikz.tex", standalone=True) # You could also directly build the pdf pykz.io.export_pdf_from_file("low_level_tikz.tex") .. image-sg:: /gallery/images/sphx_glr_low_level_tikz_002.png :alt: low level tikz :srcset: /gallery/images/sphx_glr_low_level_tikz_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 'low_level_tikz.pdf' .. GENERATED FROM PYTHON SOURCE LINES 62-77 Alternatively, output it to png .. code-block:: python pykz.io.export_png_from_file("low_level_tikz.tex") Or, save the Tikz code to a temporary file, compile it, and open the pdf in the default viewer. This would be the equivalent to ``plt.show()`` .. code-block:: python pykz.preview() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.529 seconds) .. _sphx_glr_download_gallery_low_level_tikz.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: low_level_tikz.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: low_level_tikz.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: low_level_tikz.zip ` .. include:: low_level_tikz.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_