Last active
July 5, 2018 21:59
-
-
Save MCMaurer/acda00475120e850ca213f9abfde51eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download file from here http://getdrawings.com/line-drawing-of-animals#line-drawing-of-animals-16.jpg | |
library(raster) | |
library(tidyverse) | |
# make a raster from your downloaded image | |
test_raster <- raster("../../Downloads/line-drawing-of-animals-16.jpg") | |
# extract the coordinates with a low value (black lines from the original drawing) | |
coords <- coordinates(test_raster)[values(test_raster) < 200,] | |
# turn it into a data.frame, but only use every 80th value (can tweak depending on how sparse you want the scatter) | |
coords_df <- as.data.frame(coords)[c(rep(FALSE,79), TRUE),] | |
# plot with some jitter to look more scatter-y. Probably wanna tweak this a bit depending on how you want it to look. | |
ggplot(coords_df, aes(x = x, y = y))+ | |
geom_jitter(width = 10, height = 10) | |
# if you want to plot in base and still get the "scattery" look, I think you could just add some noise to every X and Y coordinate in coords_df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment