panTeX
Generating pretty reports using pandas and matplotlib, Seaborn or Altair.
Installation
pip install pantexto install the main application- Install MiKTeX (on Windows) or TBD on Linux
- Install pandoc
- Install Browsersync (for browser mode):
npm install -g browser-sync - Install chromdriver.exe for Altair and make sure it's on your system path
Quickstart
To create a pantex.Manager object:
m = pantex.Manager('mytemplate.md')
To save context to mytemplate.pkl:
m.save_context({'my_header': 'Hello World!', 'my_table': df.head()})
To append to context in a Python script:
m.save_context({'my_footer': 'Goodbye!', 'an_image': mplFigure}, append=True)
To generate a pretty pdf report:
m.save_to_pdf()
To read the current context in a Python script: m.get_context()
m.get_context()
To generate a pdf report using a in-memory context dictionary:
m = pantex.Manager('mytemplate.md', {'my_header': 'Hello World!', 'my_table': df.head()})
m.save_to_pdf()
Quickstart via Command Line
To run in browser mode: python -m pantex.edit mytemplate.md
To prduce a pretty LaTeX pdf report: python -m pantex.publish mytemplate.md
How it works
Inspired by traditional website rendering, a report generation process is divided into two parts:
- A markdown template with Python-native template variables.
- A context dictionary, which is saved at
mytemplate.pkl
For example, say you have a markdown file at ./mytemplate.md, containing:
# ${my_header}
${my_table}
Some text
In Python, you can write:
m = pantex.Manager('mytemplate.md')
m.save_context({'my_header': 'Hello World!', 'my_table': df.head()})
m.save_to_pdf()
panTeX will combine the markdown template and the Python context and produce a pretty pdf LaTeX report.
Note that pandas DataFrame objects will be automatically rendered as a table. Matplotlib/Seaborn
charts and LaTeX style equations are also supported. (The LaTeX equations must be contained in \begin{equation}/\end{equation} tags.)
matplotlib and Seaborn plot can also be added to the context. For example,
import seaborn as sns
sns.set_theme()
df = sns.load_dataset("tips")
sns_plot = sns.relplot(
data=df,
x="total_bill",
y="tip",
col="time",
hue="smoker",
style="smoker",
size="size",
)
m = pantex.Manager('mytemplate.md')
m.save_context({'pretty_figure': sns_plot}, append=True) # "Pretty Figure" will be the image caption
Behind the scenes, panTeX saves the image at assets/pretty_figure.eps and adds 
to the rendered version of markdown file.
The Development Server (Edit Mode)
python -m pantex.edit mytemplate.md enables an in-browser version of the LaTeX report. It's not quite as pretty as the pdf version, but it offers a near real time rendering experience. (Rendering of pdf reports is typically too slow for editing and requires
the file to re-opened after each render.) If you need the html files, they can be found at mytemplate.html and assets/.
Metadata
Release files for panTeX 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| panTeX-0.0.9.tar.gz | 9.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| panTeX-0.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / panTeX-0.0.9.tar.gz
| Download URL | panTeX-0.0.9.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29797902910c998e1349ffe0aa2674a4774a1458dc783255a81611b81dbc3418
|
|
BLAKE2b-256 checksum How to use checksums |
1bef25c2b42fb1472378ee848c4d7b52a2f0cb645a8e43379ab95396b17ef48f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.7
|
Release files / panTeX-0.0.9-py3-none-any.whl
| Download URL | panTeX-0.0.9-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7833678909c7fcebc5679888c6cff49cd397e50cab1699991b213df1597fbf6c
|
|
BLAKE2b-256 checksum How to use checksums |
4c8584ed07a070564eb3b826d7003aae9eb9df58cabcc3eb3dff099c39948b52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.7
|