Skip to main content

Extract raw data from plots images

Project description

Python applicationPyPI version

A Python3 utility to digitize plots.

Installation

$ python3 -m pip install plotdigitizer 
$ plotdigitizer --help

Usage

First, remove all text from the image, leave only axis and the plot. I use gthumb utility. You can also use imagemagick or gimp.

Following image is from MacFadden and Koshland, PNAS 1990 after trimming. One can also remove top and right axis.

Trimmed image

Run the utility

plotdigitizer ./figures/trimmed.png -p 0,0 -p 10,0 -p 0,1

We need three points (-p option) to map axes onto the images. In the example above, these are 0,0 (where x-axis and y-axis intesect) , 20,0 (a point on x-axis) and 0,1 (a point on y-axis). To map these points on the image, you will be asked to click on these points on the image. Make sure to click in the same order and click on the points as precisely as you could. Any error in this step will propagate.

The data-points will be dumped to a csv file e.g., --output /path/to/file.csv.

If --plot output.png is passed, a plot of the extracted data-points will be saved to output.png. This requires matplotlib.

Notice the errors near the boxes; since we have not trimmed them.

Using in batch mode

You can also pass the location of points in the image at the command prompt. This allows it to run in the batch mode without any need for the user to click on the image.

plotdigitizer ./figures/trimmed.png -p 0,0 -p 20,0 -p 0,1 -l 22,295 -l 142,295 -l 22,215 --plot output.png

Examples

original

plotdigitizer figures/graphs_1.png \
		-p 1,0 -p 6,0 -p 0,3 \
		-l 165,160 -l 599,160 -l 85,60 \
		--plot figures/graphs_1.result.png \
		--preprocess

reconstructed

original

plotdigitizer  figures/ECGImage.png \
		-p 1,0 -p 5,0 -p 0,1 -l 290,337 \
		-l 1306,338 -l 106,83 \
		--plot figures/ECGImage.result.png

reconstructed

Limitations

Currently this script has following limitations:

  • Background must not be transparent. It might work with transparent background but I've not tested it.
  • Only b/w images are supported for now. Color images will be converted to grayscale upon reading.
  • One image should have only one trajectory.

Related projects by others

  1. WebPlotDigitizer by Ankit Rohatagi is very versatile.

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

plotdigitizer-0.1.2.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

plotdigitizer-0.1.2-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file plotdigitizer-0.1.2.tar.gz.

File metadata

  • Download URL: plotdigitizer-0.1.2.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.10.5-1-default

File hashes

Hashes for plotdigitizer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dc06f55d1e6851b93d932b6d539f4fceec8c2067d8baa4f8b4ec13528ae050e3
MD5 629e7d24de90be5c46a88a9ab7968a2c
BLAKE2b-256 6a64f8f431ef35e36d2ab4ad1e6a7d5fdaceecd83f9b5a53885fffccffeaa12d

See more details on using hashes here.

File details

Details for the file plotdigitizer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: plotdigitizer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.10.5-1-default

File hashes

Hashes for plotdigitizer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 45a5d4bbd27f63b8e076f4cdda1257eb98cd56a8f46f18a63a43d210fce3afb6
MD5 8abec7bcd1bd56bfef424ec0b3c89843
BLAKE2b-256 a34040ceb287f00781c955d360d73d7258b1f446440dcb1807ed86a7360e95c3

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