I am looking at this stackpost over here : How can I plotly a ggplot treemap?
I am able to make a mosaic plot/tree map with the following code using the plotly library:
library(plotly)
dtd7 <- structure(
list(
topic = structure(
c(9L, 8L, 4L, 7L, 2L, 6L, 1L, 3L,
5L, 10L, 13L, 11L, 12L),
.Label = c("Apple", "Avocado", "Banana", "Carrot", "Mango","Mushroom", "Onion", "Orange", "Pineapple", "Strawberry", "Sweet-lemon", "Watermelon", "Wildberry"),
class = "factor"
),
n = structure(
c(4L, 3L, 9L, 11L, 12L, 2L, 1L, 6L, 10L, 5L,
7L, 8L, 1L),
.Label = c("23", "24", "36", "42", "43", "46", "48", "52", "56", "61", "82", "94"),
class = "factor"
)
),
class = "data.frame",
row.names = c(NA,-13L)
)
p <- plot_ly(
dtd7,
labels = ~ topic,
parents = NA,
values = ~ n,
type = 'treemap',
hovertemplate = "Ingredient: %{label}<br>Count: %{value}<extra></extra>"
)
p
The computer I am using for work does not have a USB port or an internet connection. It only has R with a few libraries (plotly is not included).
Is it possible to replicate this plot only using ggplot2?
Thanks