{"id":19203170,"url":"https://github.com/dilawar/plotdigitizer","last_synced_at":"2025-04-06T16:11:17.611Z","repository":{"id":43612826,"uuid":"140683649","full_name":"dilawar/PlotDigitizer","owner":"dilawar","description":"A Python utility to digitize plots.","archived":false,"fork":false,"pushed_at":"2024-08-10T15:59:59.000Z","size":2255,"stargazers_count":136,"open_issues_count":11,"forks_count":23,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-30T15:07:58.068Z","etag":null,"topics":["data-extraction","digitization","image-processing","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dilawar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-12T08:20:45.000Z","updated_at":"2025-03-16T20:16:41.000Z","dependencies_parsed_at":"2022-09-17T15:22:20.895Z","dependency_job_id":"d293caca-6605-4d4a-b223-920de9c62331","html_url":"https://github.com/dilawar/PlotDigitizer","commit_stats":{"total_commits":117,"total_committers":4,"mean_commits":29.25,"dds":"0.41025641025641024","last_synced_commit":"565b89911d92ac5bcbffe4aa1ec60232369446df"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2FPlotDigitizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2FPlotDigitizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2FPlotDigitizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilawar%2FPlotDigitizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dilawar","download_url":"https://codeload.github.com/dilawar/PlotDigitizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509221,"owners_count":20950232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-extraction","digitization","image-processing","python3"],"created_at":"2024-11-09T12:47:13.840Z","updated_at":"2025-04-06T16:11:17.584Z","avatar_url":"https://github.com/dilawar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Python application](https://github.com/dilawar/PlotDigitizer/workflows/Python%20application/badge.svg) [![PyPI version](https://badge.fury.io/py/plotdigitizer.svg)](https://badge.fury.io/py/plotdigitizer) [![DOI](https://zenodo.org/badge/140683649.svg)](https://zenodo.org/badge/latestdoi/140683649)\n\nA Python3 command line utility to digitize plots in batch mode.\n\nThis utility is useful when you have a lot of similar plots such as EEG, ECG recordings. See examples below.\n\nFor one-off use cases, you will find web-based digitizer [WebPlotDigitizer](https://apps.automeris.io/wpd4/) \nby Ankit Rohatagi much more easier to use.\n\n## Installation\n\n```\n$ python3 -m pip install plotdigitizer\n$ plotdigitizer --help\n```\n\n## Preparing image\n\nCrop the image and leave only axis and trajectories. I used the `gthumb` utility on Linux. \nYou can also use `imagemagick` or `gimp`.\n\nThe following image is from MacFadden and Koshland, PNAS 1990 after trimming. One\nshould also remove top and right axes. I didn't because I want to highlight the \nlimitation of this tool!\n\n![Trimmed image](./figures/trimmed.png)\n\n__Run__\n\n```bash\nplotdigitizer ./figures/trimmed.png -p 0,0 -p 10,0 -p 0,1\n```\n\nWe need at least three points (`-p` option) to map x- and y-axis onto the image.  \n\nIn the example above, these are `0,0` (where x-axis and y-axis intersect) , `10,0` (a point on\nthe x-axis), and `0,1` (a point on the y-axis). To map these points on the image, you\nwill be asked to click on these points. _Make sure to click in the same order and click on\nthe points as precisely as you could. Any error in this step will propagate._ \n\nIf you don't have `0,0` in your image, you must provide 4 points: 2 on the x-axis and 2 on the y-axis.\n\nThe data points will be dumped to a CSV file specified by __`--output\n/path/to/file.csv`__.\n\nIf `--plot output.png` is passed, a plot of the extracted data points will be\nsaved to `output.png`. This requires matplotlib. Very useful when debugging/testing.\n\n![](./figures/traj.png)\n\nNotice the error near the right y-axis.\n\n## Using in batch mode\n\nYou can pass the coordinates of points in the image at the command prompt.\nThis allows it to run in batch mode without any need for the user to click on\nthe image.\n\n```bash\nplotdigitizer ./figures/trimmed.png -p 0,0 -p 20,0 -p 0,1 -l 22,295 -l 142,295 -l 22,215 --plot output.png\n```\n\n### How to find coordinates of axes points\n\nIn the example above, point `0,0` is mapped to coordinate `22,295` i.e., the\ndata point `0,0` is on the 22nd row and 295th column of the image (_assuming that the bottom left\nof the image is the first row, first column `(0,0)`_). I have included a utility\n`plotdigitizer-locate` (script `plotdigitizer/locate.py`), which you can use to\nfind the coordinates of points.\n\n\n```bash\n$ plotdigitizer-locate figures/trimmed.png\n```\n\nor, by directly using the script:\n\n```bash\n$ python3 plotdigitizer/locate.py figures/trimmed.png\n```\n\nThis command opens the image in a simple window. You can click on a point, and\nits coordinates will be written on the image. Note them down.\n\n![](./figures/trimmed_locate.png)\n\n\n# Examples\n\n### Base examples\n\n```bash\nplotdigitizer figures/graphs_1.png \\\n\t\t-p 1,0 -p 6,0 -p 0,3 \\\n\t\t-l 165,160 -l 599,160 -l 85,60 \\\n\t\t--plot figures/graphs_1.result.png \\\n\t\t--preprocess\n```\n\n![original](./figures/graphs_1.png)\n![reconstructed](./figures/graphs_1.result.png)\n\n### Light grids\n\n```\nplotdigitizer  figures/ECGImage.png \\\n\t\t-p 1,0 -p 5,0 -p 0,1 \\\n        -l 290,337 -l 1306,338 -l 106,83 \\\n\t\t--plot figures/ECGImage.result.png\n```\n\n![original](./figures/ECGImage.png)\n![reconstructed](./figures/ECGImage.result.png)\n\n### With grids\n\n```\nplotdigitizer  figures/graph_with_grid.png \\\n\t\t-p 200,0 -p 1000,0 -p 0,50 \\\n        -l 269,69 -l 1789,69 -l 82,542 \\\n\t\t--plot figures/graph_with_grid.result.png\n```\n\n![original](./figures/graph_with_grid.png)\n_Image credit: Yang yi, Wang_\n\n![reconstructed](./figures/graph_with_grid.result.png)\n\n__Note that legend was not removed in the original figure and it has screwed up\nthe detection below it.__\n\n# Limitations\n\nThis application has the following limitations:\n\n- Only b/w images are supported for now. Color images will be converted to grayscale upon reading.\n- Each plot should have only one trajectory.\n\n## Need help\n\nOpen an issue and please attach the sample plot.\n\n## Related Projects\n\n1.  [WebPlotDigitizer](https://apps.automeris.io/wpd4/) by Ankit\nRohatagi is very versatile.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilawar%2Fplotdigitizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdilawar%2Fplotdigitizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilawar%2Fplotdigitizer/lists"}