Open FinScience opened 7 years ago
## Loading packages
library("data.table")
library("D3partitionR")
library(titanic)
require(magrittr)
require(RColorBrewer)
## Reading data
titanic_data = data.table(titanic::titanic_train)
var_names=c('Sex','Embarked','Pclass','Survived') data_plot=titanic_data[,.N,by=var_names] data_plot[,(var_names):=lapply(var_names,function(x){data_plot[[x]]=paste0(x,' ',data_plot[[x]]) })]
color_list=c("#ffff00","#0000ff","#ff0000") names(color_list)<-c('Sex male','Sex female','Survived 0')
D3partitionR() %>% D3partitionR::add_data(data_plot,count = 'N',tooltip=c('name'),steps=c('Sex','Embarked','Pclass','Survived')) %>% set_chart_type('treemap') %>% set_legend_parameters(zoom_subset=T)%>% set_discrete_color_scale(color_list)%>% plot()
Hi,
I am using your package to create a visualization. However, I am not sure how to control colors,remove or rename root. It would be great if you could help me out with this.
Any help would be great