.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/circles_and_squares.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_circles_and_squares.py: Directly using Tikz ===================== Directly use Tikz functionality, without pgfplots. .. GENERATED FROM PYTHON SOURCE LINES 7-23 .. code-block:: Python import pykz pykz.figure() rect = pykz.rectangle((-1, -1), (1, 1)) circle = pykz.circle((2, 0), (1), fill="red") rect2 = pykz.rectangle((1, 1), (2, 3), fill="cyan") # Dump the generated tikz code to the stdout. print(pykz.dumps()) # Export your tex code as a standalone file pykz.save("circles_and_squares.tex", standalone=True) # You could also directly build the pdf pykz.io.export_pdf_from_file("circles_and_squares.tex") .. image-sg:: /gallery/images/sphx_glr_circles_and_squares_001.png :alt: circles and squares :srcset: /gallery/images/sphx_glr_circles_and_squares_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none \documentclass[tikz, margin=5]{standalone} \begin{document} \begin{tikzpicture} \draw(-1.000000000, -1.000000000) rectangle (1.000000000, 1.000000000); \draw[fill=red](2.000000000, 0.000000000) circle (1); \draw[fill=cyan](1.000000000, 1.000000000) rectangle (2.000000000, 3.000000000); \end{tikzpicture} \end{document} 'circles_and_squares.pdf' .. GENERATED FROM PYTHON SOURCE LINES 24-39 Alternatively, output it to png .. code-block:: python pykz.io.export_png_from_file("circles_and_squares.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.304 seconds) .. _sphx_glr_download_gallery_circles_and_squares.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: circles_and_squares.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: circles_and_squares.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: circles_and_squares.zip ` .. include:: circles_and_squares.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_