Get the data from a graph by providing calibration points
if(!require(devtools)) install.packages('devtools')
devtools::install_github("tpoisot/digitize")
## make a temporary file
tmp <- tempfile()
png(tmp)
plot(rnorm(10) + 1:10, xlab="x", ylab="y")
dev.off()
#> quartz_off_screen
#> 2
library(digitize)
## follow instructions on console, printed out below
mydata <- digitize(tmp)
#> ...careful how you calibrate.
#> Click IN ORDER: x1, x2, y1, y2
#>
#> Step 1 ----> Click on x1
#> |
#> |
#> |
#> |
#> |________x1__________________
#>
#> Step 2 ----> Click on x2
#> |
#> |
#> |
#> |
#> |_____________________x2_____
#>
#>
#> Step 3 ----> Click on y1
#> |
#> |
#> |
#> y1
#> |____________________________
#>
#>
#> Step 4 ----> Click on y2
#> |
#> y2
#> |
#> |
#> |____________________________
#>
#>
#> What is the return of x1 ?
#>
#> What is the return of x2 ?
#>
#> What is the return of y1 ?
#>
#> What is the return of y2 ?
#>
#>
#>
#> ..............NOW .............
#>
#> Click all the data. (Do not hit ESC, close the window or press any mouse key.)
#>
#> Once you are done - exit:
#>
#> - Windows: right click on the plot area and choose 'Stop'!
#>
#> - X11: hit any mouse button other than the left one.
#>
#> - quartz/OS X: hit ESC
#> Error in model.frame.default(formula = c(x1, x2) ~ c(x), drop.unused.levels = TRUE): invalid type (NULL) for variable 'c(x)'
citation('digitize')
#>
#> Poisot, T. The digitize package: extracting numerical data from
#> scatterplots. The R Journal 3.1 (2011): 25-26.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Article{,
#> title = {The digitize package: extracting numerical data from scatterplots},
#> author = {T. Poisot},
#> journal = {The R Journal},
#> year = {2011},
#> volume = {3},
#> number = {1},
#> pages = {25-26},
#> url = {http://rjournal.github.io/archive/2011-1/RJournal_2011-1.pdf#page=25},
#> }
Works with three bitmap image formats (jpeg, png, bmp), automatically detecting
the image type using package readbitmap
.
Read a tutorial from Luke Miller.