Skip to main content

plottwist makes plots reproducible from their PDFs.

Project description

plottwist

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plottwist_py-1.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plottwist_py-1.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file plottwist_py-1.0.1.tar.gz.

File metadata

  • Download URL: plottwist_py-1.0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for plottwist_py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d8577e2217a8c23dd637f1c160d81b40239d1c92078717b464d4c4eed9480a44
MD5 d72b92d1fafe8ce21db6e9b07dfd8461
BLAKE2b-256 6647017a2f011f69f0bbc101d572d8f4298259f1234be40039ce37b0f46eb3f7

See more details on using hashes here.

File details

Details for the file plottwist_py-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: plottwist_py-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for plottwist_py-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42e017f9277f01ab01d40822f1d97c629455895f0735d5dadcae0724f52e8ac5
MD5 d740cf502a2e43e5bd09982c4ffa838f
BLAKE2b-256 d429683bd3a024a737cbb0251c35942ab934f720e85af8a23c8a06b58beebd98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page