Closed kamaulindhardt closed 3 years ago
I managed.. Not very intuitively but I managed 👏
# Visualize with the treemap function
# Proportions of ERA Theme data treemap
# Using the "Set2" colour palette from RColorBrewer
png(filename="tree.png",width=800, height=800)
ERA_tree_theme_practices <- (treemap::treemap(ERA.Compiled.Split.Pracs,
index=c("Theme.Combo","PrName.Combo"),
vSize="N.Studies",
type="index",
palette = "Set2",
border.col=c("black","white"),
border.lwds=c(5,1),
fontsize.title=12,
title="Proportion of ERA theme and practices based on the number of studies for each ERA theme and practice"))
# Interactive treemap using the d3treeR package function d3tree()
ERA_tree_theme_practices_d3viz <- d3tree(ERA_tree_theme_practices,
id = "name",
celltext = "name",
valueField = "size",
width = 800, height = 600)
# saving the treemap using save_d3_html() function from the package r2d3
save_d3_png(ERA_tree_theme_practices_d3viz,
file = "ERA_tree_theme_practices_d3viz.png",
delay = 2,
zoom = 1
)
This gave me two static treemaps:
and one interactive:
Hi,
I love the treemap as a cool initial explorative data analysis visualisation and the treemap function is excellent! I am currently building a website using Distill for RMarkdown and wish to include some of my treemaps, however, I cannot find a code-friendly way to save my treemap outputs into a png that I can plot on my website.
Any solution. Thank you!
Currently, I have this in my R markdown where I make a treemap, turn it into an interactive form using d3tree
{r Splitting ERA data and viewing proportions of practices for themes in all ERA data, code_folding=TRUE, layout="l-body-outset", fig.width=12, fig.height=10, fig.cap="Proportion of ERA theme and practices"}
and when I try to save the interactive d3 treemap I get this:
This was the only way I could find to save my treemap yet I am sure there is a more straight forward one..?