Note
Go to the end to download the full example code.
Minimal working example#
Minimal working example of pykz, plotting a simple sine function.
import numpy as np
import pykz
x = np.linspace(0, 10, 100)
y = np.sin(x)
pykz.plot(x, y)
# Export your tex code as a standalone file
pykz.save("basic_inline.tex", standalone=True)
# You could also directly build the pdf
pykz.io.export_pdf_from_file("basic_inline.tex")

/home/runner/work/pykz/pykz/pykz/exceptions.py:8: SyntaxWarning: "\{" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\{"? A raw string is also an option.
message = f"{self._decode_message(parent)}\n\{self.cmd_name} failed with the error above ☝️ "
Removing basic_inline.log
Removing basic_inline.aux
PosixPath('basic_inline.pdf')
Alternatively, output it to png
pykz.io.export_png_from_file("basic_inline.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()
pykz.preview()
Total running time of the script: (0 minutes 0.732 seconds)
Related examples