Skip to content

Instantly share code, notes, and snippets.

@valerio-vaccaro
Created June 10, 2018 12:22
Show Gist options
  • Save valerio-vaccaro/7b183cc196a315be243ba59c32883070 to your computer and use it in GitHub Desktop.
Save valerio-vaccaro/7b183cc196a315be243ba59c32883070 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(jsonlite)
btc_summary <- as.data.frame(read.csv("https://api.blockchair.com/bitcoin/blocks?q=time(2018-01-01..2020-01-01)&s=id(desc)&u=4ba227b6-374f-4dba-a597-97d7db8cef61&fields=id,time,guessed_miner,transaction_count,witness_count,output_total,fee_total,fee_per_kb,size,stripped_size&export=csv"))
bch_summary <- as.data.frame(read.csv("https://api.blockchair.com/bitcoin-cash/blocks?q=time(2018-01-01..2020-01-01)&s=id(desc)&u=b703569b-7167-4c79-9c89-6a4375e1ef21&fields=id,time,guessed_miner,transaction_count,output_total,fee_total,fee_per_kb,size&export=csv"))
btc_summary$time <- as.POSIXct(btc_summary$time)
bch_summary$time <- as.POSIXct(bch_summary$time)
btc_summary$size <- btc_summary$size/(1024*1024)
bch_summary$size <- bch_summary$size/(1024*1024)
ggplot(NULL) +
geom_point(data=btc_summary, aes(x=time, y=size, color="BTC"), alpha=0.1) +
geom_point(data=bch_summary, aes(x=time, y=size, color="BCH"), alpha=0.1) +
labs(title="BTC vs BCH block size",
x ="Timestamp", y = "Block size (MB)") +
geom_hline(yintercept = 1) +
theme(axis.text.x = element_text(angle=45, hjust=1)) +
annotate("text", x = max(btc_summary$time), y = Inf, label = paste0("valeriovaccaro.it"),
hjust=1.1, vjust=1.1, col="black", cex=4,
fontface = "bold", alpha = 0.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment