{"id":24711,"library":"tikzplotlib","title":"tikzplotlib","description":"tikzplotlib is a Python tool that converts matplotlib figures into TikZ/PGFPlots code, enabling LaTeX-friendly vector graphics. Current version 0.10.1, requires Python >=3.7. Released irregularly.","status":"active","version":"0.10.1","language":"python","source_language":"en","source_url":"https://github.com/nschloe/tikzplotlib","tags":["tikz","pgfplots","matplotlib","conversion","latex"],"install":[{"cmd":"pip install tikzplotlib","lang":"bash","label":"pip"}],"dependencies":[{"reason":"required for array handling","package":"numpy","optional":false},{"reason":"required for figure handling","package":"matplotlib","optional":false}],"imports":[{"note":"common mistake: importing the old submodule 'save' directly; use 'tikzplotlib.save' instead.","wrong":"from tikzplotlib import save as tikz_save","symbol":"tikzplotlib","correct":"import tikzplotlib"}],"quickstart":{"code":"import matplotlib.pyplot as plt\nimport numpy as np\nx = np.linspace(0, 2*np.pi, 100)\nplt.plot(x, np.sin(x))\nplt.title('Simple sine wave')\ntikzplotlib.save('sine_wave.tex')","lang":"python","description":"Convert a matplotlib figure to a TikZ file using tikzplotlib.save()."},"warnings":[{"fix":"Assign the return value or check if None when providing a filename. Use 'return_str=False' to suppress string output.","message":"In tikzplotlib 0.10.x, the function 'tikzplotlib.save()' now returns the TikZ code as a string if no filename is given. Previously, it always wrote to a file. This can break scripts that do not expect a return value.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Replace 'from tikzplotlib.save import ...' with 'import tikzplotlib' and call 'tikzplotlib.save(...)'.","message":"The module 'tikzplotlib.save' is deprecated since 0.9.0. Use 'tikzplotlib.save()' directly (the function, not a submodule).","severity":"deprecated","affected_versions":">=0.9.0"},{"fix":"Always call plt.show() or ensure the figure is properly closed before saving, or use tikzplotlib with 'plt.gcf()'.","message":"tikzplotlib requires matplotlib to be installed and the figure to be fully rendered before calling save. Otherwise, the output may be incomplete or raise AttributeError.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install tikzplotlib' and ensure the environment is correct.","cause":"Library not installed or pip install failed.","error":"ModuleNotFoundError: No module named 'tikzplotlib'"},{"fix":"Use 'import tikzplotlib' and call 'tikzplotlib.save()'. For versions <0.9.0, use 'from tikzplotlib import save as tikz_save'.","cause":"Version mismatch or incorrect import path.","error":"AttributeError: module 'tikzplotlib' has no attribute 'save'"},{"fix":"Provide filepath as positional: 'tikzplotlib.save('output.tex')' or keyword: 'tikzplotlib.save(filepath='output.tex')'.","cause":"Passing both positional and keyword argument for filepath.","error":"TypeError: save() got multiple values for argument 'filepath'"},{"fix":"Create a figure with 'plt.figure()' or 'plt.plot()' before calling save.","cause":"No figure has been created or the figure has been closed.","error":"ValueError: Cannot save an empty figure"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}