Dot Scraper webapp

For a lot of my chart recreations, the source data isn’t readily available, and I have to infer it from the image, often by clicking on every dot to get its position. Tools like WebPlotDigitizer make that doable and provide some basic automatic mark-detection features. However, I haven’t found any tools that work well with lots of overlapping dots. Over the past few weeks, I’ve been using Claude to make a webapp for just that, called Dot Scraper.

My idea was to identify a few dots, mask out non-dots, and then iteratively try to account for the remaining ink as additional copies of the identified dots. Those steps are all fuzzy and non-trivial but can be done reasonably well in a browser. It works great for the cases I had in mind, such as this before-and-after example from the GitHub readme.

However, I quickly learned that “if you’ve seen one scatterplot, you’ve seen one scatterplot.” Realizing that, my main job became finding suitable test images and then directing Claude to refine the implementation. I pulled samples from Nature, PLOS, and PubMed and added graphs locally made in JMP and R. The local images and those with friendly licenses are included in the repo. Here’s a sample from the whole suite of about 200 images.

collage of 24 snippets of scatterplots used for testing

Complications

Besides finding good test images, the main complications have been:

  • Outlined dots, especially hollow dots. The initial design uses a circle-detection algorithm that expects. Sometimes outlined dots could be detected as two dots of different sizes at the same location, but they needed to be seen as a single dot. Outlines mostly work now, but I wonder if they should have been built-in better from the beginning instead of added on later.
  • Overlaid regions, like box plots and filled confidence regions. Those were expected to be troublesome, but now the app does a decent job with them.
  • Low-resolution images. Many online papers only have JPG images of limited resolution, which are more challenging to detect. I learned I can often get better quality images from the PDF version of the paper.
  • Axis variety. I knew dots would vary from chart to chart, but I forgot how much axes vary. Ticks or no ticks, line or no line, scientific notation labels, categorical axes, … Still I ended up with passable axis detection including minimal built-in OCR to read numbers.

Manual editing

The auto-detection will never be perfect, so it’s important to support manual editing of dot locations. That took many iterations, but I think it’s quite useful now. So much so that I would find the app useful in case where the automatic detection doesn’t find anything. One nice feature I didn’t explicitly ask for but Claude implemented is that clicking to add a dot will center the click location on the nearest plausible dot (unless you override with the option key — I did ask for that part).

Future

The app is working well, but each new scatterplot finds new areas for improvements, so the work will never be done.

  • Rework outlined dot detection (if the current limitations get too annoying)
  • Other marker shapes — sounds simple, but a lot of the logic is built around circle and arc detection.
  • Size-encoded dots, as in bubble plots
  • Better axis detection, especially for categorical axes
  • Speed — scanning an image for dots and then running the detection iteration can take a few seconds or much longer. Good results are worth the wait, but I wonder about potential inefficiencies. Speed is mainly an issue when running the test suite, which can take 20 minutes even using 10 parallel workers.
  • Mask customization — masking out the non-dot contents is now automatic, but sometimes it’s wrong and it would be nice to manually edit it.


Leave a Reply