We’re doing some interesting studies (cybersecurity-wise, not finance-wise) on digital currency networks at work-work and — while I’m loathe to create a geo-map from IPv4 geolocation data — we:
- do get (often, woefully inaccurate) latitude & longitude data from our geolocation service (I won’t name-and-shame here); and,
- there are definite geo-aspects to the prevalence of mining nodes — especially Bitcoin; and,
- I have been itching to play with the nascent nord palette in a cartographical context…
so I went on a small diversion to create a bubble plot of geographical Bitcoin node-prevalence.
I tweeted out said image and someone asked if there was code, hence this post.
You’ll be able to read about the methodology we used to capture the Bitcoin node data that underpins the map below later this year. For now, all I can say is that wasn’t garnered from joining the network-proper.
I’m including the geo-data in the gist, but not the other data elements (you can easily find Bitcoin node data out on the internets from various free APIs and our data is on par with them).
I’ve blathered a bit about nord, so let’s start with that (and include the various other packages we’ll use later on):
library(swatches) library(ggalt) # devtools::install_github("hrbrmstr/ggalt") library(hrbrthemes) # devtools::install_github("hrbrmstr/hrbrthemes") library(tidyverse) nord
It may not be a perfect palette (accounting for all forms of vision issues and other technical details) but it was designed very well (IMO).
The rest is pretty straightforward:
- read in the bitcoin geo-data
- count up by lat/lng
- figure out which colors to use (that took a bit of trial-and-error)
- tweak the rest of the ggplot2 canvas styling (that took a wee bit longer)
I’m using development versions of two packages due to their added functionality not being on CRAN (yet). If you’d rather not use a dev-version of
hrbrthemes just use a different
ipsum theme vs the new
read_csv("bitc.csv") %>% count(lng, lat, sort = TRUE) -> bubbles_df world
As noted, the RStudio project associated with this post in in this gist. Also, upon further data-inspection by @jhartftw, we’ve discovered yet-more inconsistencies in the geo-mapping service data (there are way too many nodes in Paris, for example), but the main point of the post was to mostly show and play with the nord palette.
R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more…
Source:: R News