dcmvdbekerom/pypdfplot

Created Jan 3, 2021 · View the dcmvdbekerom/pypdfplot repository page

Pypdfplot uses pyplot to produce plots in PDF-format with the python script and data files embedded. The plot can be edited by changing filename from .pdf to .py and running the script again.

Want this for your repo?

Render a free sample of any GitHub repo in seconds.

Visualize your own →

Contributors

2

Lines of Code

670

From

Jun 10, 2018

To

Jan 2, 2021

About dcmvdbekerom/pypdfplot

Pypdfplot is a Python package that provides a custom Matplotlib backend for generating PDF files with the generating Python script embedded inside them. The core innovation is that the output file is simultaneously a valid PDF document and a valid Python script, achieved through careful ordering of data blocks so that PDF readers see the Python code as an embedded file while Python interpreters read the PDF content as comments.

The workflow enables a unique editing paradigm where users can rename a saved PDF file back to .py, edit the Python script to modify the plot, and run it again to regenerate an updated PDF with the modified script embedded. This eliminates the traditional disconnect between a visualization and its source code, making the philosophy that the generating script and the plot output are one unified document. The package integrates seamlessly with Matplotlib's standard plotting API, requiring only an import of the pypdfplot backend before importing pyplot.

The project is intended for data scientists, researchers, and analysts who want to maintain reproducibility and editability of their visualizations without managing separate script and output files. Installation is straightforward via pip, with special considerations provided for Anaconda and Spyder environments. The latest version switched to the pypdf library as a dependency and added functionality to back up the original Python file within the PDF for recovery purposes.

Share this video