plottwist makes plots reproducible from their PDFs.
Project description
plottwist
plottwist makes plots reproducible from their PDFs.
Perhaps you, like me, find yourself digitizing plots to get the data back from papers. That doesn't feel right, as most plots are digital nowadays anyway.
What if we just embed the plot data directly into itself?
plottwist transparently saves you Matplotlib actions and then encodes their data and parameters into a fancy link on the plot itself.
Installation
pip install plottwist-py
Twisting
import matplotlib.pyplot as plt
import numpy as np
import plottwist
x = np.linspace(0, 1)
pt = plottwist.PlotTwist(plt.gca())
pt.plot(x, x**2, label='squared')
pt.scatter(x, x**3, label='cubed', s=10, marker='x')
pt.axvline(0.5, color="orange", linestyle='dashed')
pt.axhline(0.1, color="black", linestyle='dotted')
pt.legend(frameon=False)
pt.add_author("Ivan Markin")
pt.add_reference("https://doi.org/10.1103/6mtx-nftm")
pt.hide_at_the_origin()
plt.savefig("examples/plot.pdf", bbox_inches='tight')
Untwisting
Find the link hidden at the origin of the axes in the plot PDF, right-click, copy the URL, save it to a file, and reproduce the plot using plottwist:
import matplotlib.pyplot as plt
import plottwist
pt = plottwist.PlotTwist(plt.gca())
with open("examples/plot.plottwist") as f:
url = f.read()
pt.reproduce(url)
plt.show()
print(pt.data["metadata"])
You can try that yourself with the example file examples/plot.pdf.
Soundtrack
I keep trying to make something
Create something true
But I can't replicate you, huh
No, I can't replicate you
No, I can't replicate you, huh
Róisín Murphy - Can’t Replicate
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plottwist_py-1.0.0.tar.gz.
File metadata
- Download URL: plottwist_py-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
499982daae582531eaa58d1455c7b12be97b3aeb921145c4ddd3f7a0f619b94a
|
|
| MD5 |
8635e97594c1d42a40a185255b54f4cc
|
|
| BLAKE2b-256 |
0535e0b58adf6c743e1c55c1eb819a9331d06f11bf4120438f1bb195697e6dcc
|
File details
Details for the file plottwist_py-1.0.0-py3-none-any.whl.
File metadata
- Download URL: plottwist_py-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee07553125e1d16a7c7c52035565001b381d8e739481aa1682eb5ca436580ab1
|
|
| MD5 |
5b59e9ebe47ac06ecb31cd26a3db178d
|
|
| BLAKE2b-256 |
5a5547f0c064a57f107745b7d7645afa0b85caff13d004e62c8ba5184c6f09a9
|