wilkox / treemapify

🌳 Draw treemaps in ggplot2
http://wilkox.org/treemapify
213 stars 18 forks source link

place = "center" not working in geom_treemap_text #44

Closed DrDevSecOps closed 3 years ago

DrDevSecOps commented 3 years ago

In geom_treemap_text(), place = "center" no longer works (it used to work). It puts all the text in the center of the graphic, rather than centered in each rectangle. place = "centre" does work

This broke a bunch of existing code.

Sample code to replicate the bug:

library(treemapify) library(ggplot2) Id <- c('A','B','C','D') Value <- c(10,5,1,100) df <- data.frame(Id, Value)

ggplot(df, aes(area = Value, fill = Id, label = Value)) + geom_treemap() + geom_treemap_text(place = "center")

wilkox commented 3 years ago

Thanks for reporting this @DrDevSecOps! This issue has been fixed in version 2.5.4 which I have just released on CRAN:

library(treemapify)
packageVersion("treemapify")
#> [1] '2.5.4'
library(ggplot2)

Id <- c('A','B','C','D')
Value <- c(10,5,1,100)
df <- data.frame(Id, Value)

ggplot(df, aes(area = Value, fill = Id, label = Value)) +
geom_treemap() +
geom_treemap_text(place = "center")

Created on 2020-11-20 by the reprex package (v0.3.0)