Who’s receiving delegations? – Colored

Words
101
Reading
1 min
Listen
Play
8y


By suggestion of miniature-tiger@miniature-tiger (https://steemit.com/cryptocurrency/@miniature-tiger/re-verodato-how-s-receiving-delegations-20180612t111623751z) I put some different colors on the chart showing the main accounts receiving delegations (https://steemit.com/cryptocurrency/@verodato/how-s-receiving-delegations#@miniature-tiger/re-verodato-how-s-receiving-delegations-20180612t111623751z).

Each color represents a different type of account, as shown by the legend. I could have possibly made some errors classifying the accounts into types so please correct me if I am wrong.


The code

Now let's see the R code to build the chart. First we have to classify each top 30 account into a type.

platforms <- data.table(name = c('dlive','dsound','dtube','busy','busy.pay','utopian-io','steemhunt','steempress-io','tribesteemup','esteemapp'), type = 'platform')
bidbots <- data.table(name = c('postpromoter','appreciator','smartsteem','buildawhale','upme','rocky1','booster','therising','upmewhale','boomerang','minnowbooster','tipu'), type = 'bid-bot')
admin <- data.table(name = c('steemcleaners','spaminator'), type = 'admin')
individuals <- data.table(name = c('sweetsssj','kpine','surpassinggoogle','adamkokesh','v4vapid','canadian-coconut'), type = 'individual')
unknown <- data.table(name = c('steemed-proxy'), type = 'unknown')



Then we consolidate all the types into the "type" data.table. In the next step we associate colors to each type of account.

type <- rbind(platforms,bidbots,admin,individuals,unknown)

color <- data.table(
  color = c('#a9dba9','#ff8989','#505793','#f9ff98','#ffffff'),
  type = c('platform','bid-bot','admin','individual','unknown')
)

setkey(color,type)
setkey(type,type)
type <- merge(color,type)



The "treemap" function is almost the same as the one from the last post but it is worth showing it here because there are some subtle differences.

setkey(type,name)
setkey(top_rvc,name)
df <- data.frame( type[top_rvc][order(rvs,decreasing = T)] )

library(treemap)
treemap(df,
        index='name',
        vSize = 'rvs',
        vColor = 'color',
        type = 'color',
        title="Top 30 accounts that receive most delegations",
        fontsize.labels = 20,
        force.print.labels = T,
        overlap.labels = 0.4,
        algorithm = 'pivotSize'
)



Finally, the legend, that was built outside of the treemap function.

  esquema_cores <- color[,color]
  labels <- color[,type]
  
  grid.newpage()
  altura  <- 0.08
  largura <- 0.05
  
  x_pos <- 0.04
  for(i in 1:nrow(color)){
    
    vp <- viewport(x=x_pos,y=y_pos,width=largura,height=altura,just="bottom")
    pushViewport(vp)
    grid.rect(just="left",gp=gpar(fill = esquema_cores[i]))
    upViewport()
    
    vp <- viewport(x=x_pos + 0.07,y=y_pos,width=largura,height=altura,just="bottom")
    pushViewport(vp)
    grid.text(labels[i],just="left",gp=gpar(fontsize=14))
    upViewport()
    
    x_pos <- x_pos + 0.2  
  }



There's much more lines of code here in comparison with last post. But now we have much more information in the same chart!