Git Product home page Git Product logo

treemapify's People

Contributors

bernhard-da avatar hrbrmstr avatar mruessler avatar stijnvanhoey avatar wilkox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

treemapify's Issues

Error when installing treemapify on Mac OS 10.8 with R 3.1.1

I've tried to install treemapify on my computer (Mac OS 10.8 with R 3.1.1) but I've got the following error message :

Error : file '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/treemapify/DESCRIPTION' is not in valid DCF format

Do you have any explanation ?

xlim ylim parameters broken in 2.5

If I roll back to 2.4 ; the very helpful drilldown example works

#22

but in 2.5
are not passed and xmin/ymin do not function and errors out

xlim = c(0, 1), ylim = c(0, 1)

other parameters are warnings and deprecated if I update to what is currently 2.5.90001

Legend size overridden by subgroup border

Code example, using theme() to control the size and shape of the legend key items:

library(treemapify)

plot_11 <- ggplot(diamonds %>% head(12), 
                     aes(area = carat, fill = color, label = color, 
                         subgroup = cut, subgroup2 = color)) +
  geom_treemap(size = 3) +
  # geom_treemap_subgroup_border(color = "grey", size = 20) +
  geom_treemap_subgroup2_border(color = "grey", size = 2) +
  geom_treemap_subgroup_text(place = "center", grow = FALSE, alpha = 0.5, colour =
                               "black", fontface = "italic", min.size = 2,
                             padding.x = grid::unit(3,"mm"), padding.y = grid::unit(3,"mm") ) +
  theme(legend.key.size = unit(1, "cm"), 
        legend.key.width = unit(0.3, "cm")) +
  theme(legend.background = element_rect(fill = 'grey'))
plot_11

Result:
image

However, when geom_treemap_subgroup_border() is uncommented to introduce some separation between major groupings, the legend key sizing no longer works:
image

(Actually, it partly works. Values of legend.key.size bigger than 2 cm will take effect.)

Is there a way to use both features fully?

Error when replicating the tuto

Hello,
I faced a bug while trying to replicate the tuto. I have just changed my computer and wanted to relaunch a script using your treemap function. This script was working on the old computer but now it's failing. I have tested with your tuto (G20 dataset) and I get the message error message:
"Error : Continuous value supplied to discrete scale"

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.2
locale:
[1] fr_FR.UTF-8/fr_FR.UTF-8/fr_FR.UTF-8/C/fr_FR.UTF-8/fr_FR.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] treemapify_0.2.1 reshape2_1.4.2 ggplot2_2.2.0 plyr_1.8.4 devtools_1.12.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.8 assertthat_0.1 digest_0.6.10 withr_1.0.2 grid_3.3.2 R6_2.2.0 gtable_0.2.0 magrittr_1.5
[9] git2r_0.16.0 scales_0.4.1 httr_1.2.1 stringi_1.1.2 curl_2.3 lazyeval_0.2.0 tools_3.3.2 stringr_1.1.0
[17] munsell_0.4.3 colorspace_1.3-2 memoise_1.0.0 tibble_1.2

Problem with the new OSX or latest version of R ?

Thanks a lot for your work and your help,
Bests

Fixed size labels

Hello, I've just installed this package as I need to use treemaps in a shinydashboard application. Thank you for putting this together!!! Because I'm using shiny I'd rather use ggvis than ggplot2 to render the final plot so I may come up with some code to achieve this in the near future.

The first issue that I have, however, is the variable-sized labels. I don't thnk this adds anything to the plot - the small labels are illegible and the label sizes don't appear to be proportional to the tile size as I suspect they should be (in my case I have a small tile that has a large label next to a large tile which has a smaller label).

I'd like to raise a feature request to have the option for fixed-size labels. (Basically the same behaviour as the plots produced with the treemap package.)

Regards,

Michael

Is there a way to make squarified layouts do rows first then columns?

I almost have the layout I'm looking for, with 4 groups in my treemap, but no matter which corner I start from, I always get the x-axis split into two equally, but not the y-axis.

e.g.:

  local({
      start <- "topleft"
      layout <- "squarified"
      tibble::tibble(A = c(1,1,0,0),
                     B = c(0,1,1,0),
                     pct = c(0.69, 0.14, 0.06, 0.11)) %>%
          dplyr::mutate(label = paste("A=", A, "\n", "B=", B, sep="")) %>%
          ggplot2::ggplot(ggplot2::aes(area = pct,
                                       subgroup = A,
                                       subgroup2 = B,
                                       label = label)) +
          treemapify::geom_treemap(start = start, layout = layout) +
          treemapify::geom_treemap_text(start = start)
  })

What I'm looking for is the A=1,B=0 and A=1,B=1 groups placed along the top in boxes of equal height. I can get equal width, but not equal height and starting from different corners or reversing the subgroups doesn't seem to help.

place = "center" not working in geom_treemap_text

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")

use {ggtext} to customize labels in geom_treemap_text()

Hi,

Great package! I would like to be able to use {ggtext} to customize the geom_treemap_text().
For instance, when using HTML in the title of a plot, I would use the following code to render it:

+ theme(plot.title = ggtext::element_markdown())

Would it be possible to implement these features for assessing the text rendered with geom_treemap_text()?

Thanks

The same code second run crashes under rJava.

Under R 3.4.1, rJava 0.9-9, jdk1.8.121, win7 , The same code, first run successfully, the second run crashes, but at Rstudio, each run succeeds.

An unrecoverable stack overflow has occurred.

A fatal error has been detected by the Java Runtime Environment:

EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x2ee3fed6, pid=9032, tid=0x00001790

JRE version: Java(TM) SE Runtime Environment (8.0_121-b13) (build 1.8.0_121-b13)
Java VM: Java HotSpot(TM) Client VM (25.121-b13 mixed mode windows-x86 )
Problematic frame:
C [R.dll+0xbfed6]

Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

An error report file with more information is saved as:
x:\hs_err_pid9032.log

If you would like to submit a bug report, please visit:
http://bugreport.java.com/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.

Using ggsave does not include the text created by geom_treemap_text

I need to save the treemap as an image, but when I do so, any text is not included. This is a minimum working example":

df <- data.frame(Channel = c("Twitter", "Facebook", "YouTube"),
                 Engagement = c(1500, 150, 450))
ggplot(df, aes(area = Engagement, fill = Channel, label = Engagement)) + 
  geom_treemap() +
  scale_fill_manual(name = NULL, values = c("#3b5998", "#1DA1F2", "#FF0000")) +
  geom_treemap_text(colour = "white", place = "centre", grow = TRUE,
                    padding.x = unit(16, "mm"))
ggsave("social-media.png", width = 2.9, height = 1.3)

The treemap itself is saves, but the labels have vanished. When I remove the width and height variables, the files saves with the relevant text.

Multiple Subgroups

It would be helpful to be able to have more than one subgroup in a similar manner to the treemap::treemap() function (see example), i.e. a subgroup can contain a further subgroup.

I can produce example data if necessary.

rplot

namespace/description config

Hi @wilkox, thanks a lot for this package.

A small question. Could you consider moving the plyr (and other dependencies) to Imports instead of Depends?

The reason I'm asking this is because I use dplyr quite a lot and importing treemapify attaches plyr to the main search path an in doing so conflicts with a number of dplyr functions.

Anyway, I can work around this, but I assume it is something others bump into as well.

Error while trying to replicate the tuto

Hello,
I got this error when I tried to replicate the tutorial (both with the G20 and my own dataset)
Error: invalid (do_set) left-hand side to assignment

It occurs when I am trying to run the ggplotify function.

sessionInfo():

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
attached base packages:
[1] splines grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.9.4 treemapify_0.1 reshape2_1.4 devtools_1.6.1 Hmisc_3.16-0 Formula_1.2-1
[7] survival_2.37-7 lattice_0.20-29 knitr_1.9 stringr_0.6.2 magrittr_1.5 rvest_0.2.0
[13] httr_0.5 XML_3.98-1.1 ggplot2_1.0.0 tidyr_0.2.0 dplyr_0.4.1 plyr_1.8.1
loaded via a namespace (and not attached):
[1] acepack_1.3-3.3 assertthat_0.1 chron_2.3-45 cluster_1.15.3 colorspace_1.2-4
[6] DBI_0.3.1 digest_0.6.4 evaluate_0.5.5 foreign_0.8-61 formatR_1.0
[11] gridExtra_0.9.1 gtable_0.1.2 latticeExtra_0.6-26 lazyeval_0.1.10 MASS_7.3-35
[16] memoise_0.2.1 munsell_0.4.2 nnet_7.3-8 parallel_3.1.2 proto_0.3-10
[21] R6_2.0.1 RColorBrewer_1.0-5 Rcpp_0.11.3 rpart_4.1-8 scales_0.2.4
[26] tools_3.1.2

thanks for your work and your help.

Accessing individual treemap boxes

Hi, I am trying to access the individual treemap boxes. In the geom_treemap.R function I would like to associate with each treemap box the data rows of observations that fall into that box. For example, in the diamonds dataset, there are diamonds that satisfy cut: Ideal -> color: E -> clarity: VS1, I would like to store all records associated with those diamonds in the box for those diamonds.

I am trying to plot information on the treemap so I can see more than just the proportions, I would like to be able to draw a plot on top of the treemap boxes that tells me more about that subgroup.

Thank you so much for your time!

Can the tile placement proceeds from other directions?

Hi David,

In your description, it's said

placement proceeds from the bottom left
corner, filling alternately rightwards then upwards until all tiles are placed.

I was wondering is there other direction for the placement, e.g., from top left?

Thanks

G20 dataset

When I installed treemapify it doesn't seem to contain the G20 dataset used in the example.

geom_treemap_text() does not appear to create labels

Using the example provided in the README, geom_treemap_text() does not appear to create labels for each tile. This appears to have changed in 2.5.1 (labels were working in 2.5.0).

library(ggplot2)
library(treemapify)
ggplot(G20, aes(area = gdp_mil_usd, fill = hdi, label = country)) +
  geom_treemap() +
  geom_treemap_text(fontface = "italic", colour = "white", place = "centre",
                    grow = TRUE)

Created on 2018-10-09 by the reprex package (v0.2.1)

Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.5.1 (2018-07-02)
#>  system   x86_64, darwin17.6.0        
#>  ui       unknown                     
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2018-10-09
#> Packages -----------------------------------------------------------------
#>  package    * version date       source        
#>  assertthat   0.2.0   2017-04-11 CRAN (R 3.5.0)
#>  backports    1.1.2   2017-12-13 CRAN (R 3.5.0)
#>  base       * 3.5.1   2018-07-03 local         
#>  bindr        0.1.1   2018-03-13 CRAN (R 3.5.0)
#>  bindrcpp     0.2.2   2018-03-29 CRAN (R 3.5.0)
#>  colorspace   1.3-2   2016-12-14 CRAN (R 3.5.0)
#>  compiler     3.5.1   2018-07-03 local         
#>  crayon       1.3.4   2017-09-16 CRAN (R 3.5.0)
#>  curl         3.2     2018-03-28 CRAN (R 3.5.0)
#>  datasets   * 3.5.1   2018-07-03 local         
#>  devtools     1.13.6  2018-06-27 CRAN (R 3.5.0)
#>  digest       0.6.17  2018-09-12 CRAN (R 3.5.1)
#>  dplyr        0.7.6   2018-06-29 CRAN (R 3.5.0)
#>  evaluate     0.11    2018-07-17 CRAN (R 3.5.1)
#>  ggplot2    * 3.0.0   2018-07-03 CRAN (R 3.5.0)
#>  glue         1.3.0   2018-07-17 CRAN (R 3.5.1)
#>  graphics   * 3.5.1   2018-07-03 local         
#>  grDevices  * 3.5.1   2018-07-03 local         
#>  grid         3.5.1   2018-07-03 local         
#>  gtable       0.2.0   2016-02-26 CRAN (R 3.5.0)
#>  htmltools    0.3.6   2017-04-28 CRAN (R 3.5.0)
#>  httr         1.3.1   2017-08-20 CRAN (R 3.5.0)
#>  knitr        1.20    2018-02-20 CRAN (R 3.5.0)
#>  labeling     0.3     2014-08-23 CRAN (R 3.5.0)
#>  lazyeval     0.2.1   2017-10-29 CRAN (R 3.5.0)
#>  magrittr     1.5     2014-11-22 CRAN (R 3.5.0)
#>  memoise      1.1.0   2017-04-21 CRAN (R 3.5.0)
#>  methods    * 3.5.1   2018-07-03 local         
#>  mime         0.6     2018-10-05 CRAN (R 3.5.1)
#>  munsell      0.5.0   2018-06-12 CRAN (R 3.5.0)
#>  pillar       1.3.0   2018-07-14 CRAN (R 3.5.1)
#>  pkgconfig    2.0.2   2018-08-16 CRAN (R 3.5.1)
#>  plyr         1.8.4   2016-06-08 CRAN (R 3.5.0)
#>  purrr        0.2.5   2018-05-29 CRAN (R 3.5.0)
#>  R6           2.3.0   2018-10-04 CRAN (R 3.5.1)
#>  Rcpp         0.12.19 2018-10-01 CRAN (R 3.5.1)
#>  rlang        0.2.2   2018-08-16 CRAN (R 3.5.1)
#>  rmarkdown    1.10    2018-06-11 CRAN (R 3.5.0)
#>  rprojroot    1.3-2   2018-01-03 CRAN (R 3.5.0)
#>  scales       1.0.0   2018-08-09 CRAN (R 3.5.1)
#>  stats      * 3.5.1   2018-07-03 local         
#>  stringi      1.2.4   2018-07-20 CRAN (R 3.5.1)
#>  stringr      1.3.1   2018-05-10 CRAN (R 3.5.0)
#>  tibble       1.4.2   2018-01-22 CRAN (R 3.5.0)
#>  tidyselect   0.2.4   2018-02-26 CRAN (R 3.5.0)
#>  tools        3.5.1   2018-07-03 local         
#>  treemapify * 2.5.1   2018-10-06 CRAN (R 3.5.1)
#>  utils      * 3.5.1   2018-07-03 local         
#>  withr        2.1.2   2018-03-15 CRAN (R 3.5.0)
#>  xml2         1.2.0   2018-01-24 CRAN (R 3.5.0)
#>  yaml         2.2.0   2018-07-25 CRAN (R 3.5.1)

Intra-subgroup border color

Is it possible to modify the color of the intra-group border color (not the geom_treemap_subgroup_border)? I would like a color that has higher contrast than the default gray so it will be more visible on a projector display

original

I tried setting the colour parameter in the aes argument, but the lines become red instead.

ggplot(G20, aes(area = gdp_mil_usd, fill = hdi, label = country, subgroup = region,
            colour = "black")) +
  geom_treemap() +
  geom_treemap_subgroup_border(colour = "black")

new

I just started working with R, but does this snippet overwrite the color?

treemapify/R/geom_treemap.R

Lines 143 to 157 in c859bc3

grob <- grid::rectGrob(
x = data$xmin,
width = data$xmax - data$xmin,
y = data$ymax,
height = data$ymax - data$ymin,
default.units = "native",
just = c("left", "top"),
gp = grid::gpar(
col = data$colour,
fill = ggplot2::alpha(data$fill, data$alpha),
lwd = data$size,
lty = data$linetype,
lineend = "butt"
)
)

label.size.fixed broken?

Hey there. Possible bug:

tm = treemapify(dat, area = "n", fill = "var", label = "lab", label.size.fixed = 2)
Error in treemapify(dat, area = "posts", fill = "var", label = "lab",  : 
  unused argument (label.size.fixed = 2)

If not an example on correct usage would be much appreciated :)

Handle label resizing and colors?

Hi! Big fan of the package - your integration with ggplot2 lets me talk to shiny and plotly, which is baller.

Question / feature request: How can I change the size of the lables? Digging into the code a bit for the object I wanted I found I could then dig into the ggplot2 object and hard set some of the variables in the existing layer:
treemap.ggp$layers[[3]]$geom_params$colour="black"
treemap.ggp$layers[[3]]$data$labelsize = treemap.ggp$layers[[3]]$data$labelsize*1.5 #doesn't really work

But it'd be great to be able to pass it some of those variables from the get-go. I'm particularly stumped by size - it seems to be sizing everything proportional to the box and... and maybe the first element? Smaller boxes are illegible and I am not sure how to address it.

Best wishes! Great package. I hope it gets integrated into ggplot2 proper!

Treemapify facet wrap

Hello,
I have a question about fixing the order of the treemaps upon using facet wrap with treemapify.
In this example I have the following demo dataset where I am interested in designing a treemap for two groups (Even and Odd)

str(demo)
'data.frame': 34 obs. of 4 variables:
$ group : Factor w/ 2 levels "Even","Odd": 1 1 1 1 1 1 1 1 1 1 ...
$ parameter: Factor w/ 5 levels "A","B","C","D",..: 1 1 1 2 2 2 3 3 3 3 ...
$ status : Factor w/ 9 levels "Cold","Fragile",..: 7 5 9 7 5 9 3 1 4 9 ...
$ count : int 91 9 6 95 5 7 88 10 6 3 ...

head(demo)
group parameter status count
1 Even A Positive 91
2 Even A Negative 9
3 Even A Unknown 6
4 Even B Positive 95
5 Even B Negative 5
6 Even B Unknown 7

when I generate the figure:

treeMapPlot <- ggplot(demo, aes(area=count, fill=parameter, label=status, group=status, subgroup=parameter)) +
geom_treemap() +
facet_wrap(~group) +
scale_fill_manual(values=wes_palette(n=5, name="Moonrise3"))+
geom_treemap_text(colour = "black", place = "center",
grow = TRUE, min.size = 0) +
theme(legend.text=element_text(size=12), legend.position = "right") +
guides(fill=guide_legend(reverse=TRUE))

the order of the parameters changes in each facet. I would like to keep parameters in the same order to make the figure more visually accessible. (for example, Parameter A on the Upper right corner)

Do you have any advice for me? Sorry to bother you and sorry if my question is framed in a wrong way, this is my first time posting a question on github.

Thank you very much,
best wishes,

P.S.

My session Info is
R version 3.4.0 RC (2017-04-18 r72540)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] pals_1.5 maps_3.2.0 wesanderson_0.3.2 ggplot2_2.2.1
[5] treemapify_2.4.0 BiocInstaller_1.26.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 magrittr_1.5 knitr_1.18 munsell_0.4.3
[5] colorspace_1.3-2 xtable_1.8-2 R6_2.2.2 rlang_0.1.6
[9] plyr_1.8.4 tools_3.4.0 dichromat_2.0-0 grid_3.4.0
[13] gtable_0.2.0 htmltools_0.3.6 crosstalk_1.0.0 yaml_2.1.16
[17] lazyeval_0.2.1 digest_0.6.14 rgl_0.99.9 tibble_1.4.2
[21] shiny_1.0.5 RColorBrewer_1.1-2 mapproj_1.2-5 htmlwidgets_1.0
[25] ggfittext_0.5.0 mime_0.5 labeling_0.3 stringi_1.1.6
[29] compiler_3.4.0 pillar_1.1.0 scales_0.5.0 jsonlite_1.5
[33] httpuv_1.3.5

demo_data.txt
image

Set Colours of Subgroups?

I love TreeMapify - it has made my life so much easier! Is there a way to specify the colours of the subgroups?

For example

library(ggplot2)
library(treemapify)

name <- c("France", "Germany", "Chad", "Mali")
population <- c(100, 200, 300, 400)
parent <- c("Europe","Europe","Africa","Africa")
df <- data.frame(name, population, parent)
ggplot(df, aes(area = population, label = name, subgroup=parent, fill=parent )) +
geom_treemap() +
geom_treemap_text(colour = "white", place = "centre", grow = TRUE)

The fill=parent seems to set the colours randomly. I thought I could change it to fill=c("red", "green" ...) or use #f00 but neither of those worked.

Is there a way to specify the fill colours?

Thanks!

Forthcoming release of ggplot2 and treemapify

We are contacting you because you are the maintainer of treemapify, which imports ggplot2 and uses vdiffr to manage visual test cases. The upcoming release of ggplot2 includes several improvements to plot rendering, including the ability to specify lineend and linejoin in geom_rect() and geom_tile(), and improved rendering of text. These improvements will result in subtle changes to your vdiffr dopplegangers when the new version is released.

Because vdiffr test cases do not run on CRAN by default, your CRAN checks will still pass. However, we suggest updating your visual test cases with the new version of ggplot2 as soon as possible to avoid confusion. You can install the development version of ggplot2 using remotes::install_github("tidyverse/ggplot2").

If you have any questions, let me know!

How do I use annotate() with treemapify?

I am trying to directly annotate a treemapify plot using the annotate() function and the "label" geom. I can get the annotation to appear, but I cannot move the annotation away from the very center of the panel area. I have tried setting x, y, hjust, and vjust.

Is there any prior art on how to annotate a treemap?

Problem with aesthetics for text color in geom_treemap_subgroup*_text

Example:

library(ggplot2)
library(treemapify)
ggplot(G20, aes(area = gdp_mil_usd, fill = hdi, subgroup = hemisphere, 
        subgroup2 = region, subgroup3 = country)) + geom_treemap() +
  geom_treemap_subgroup3_text(aes(colour = region))

produces

Error in `[<-.data.frame`(`*tmp*`, aesthetic, value = c("#F8766D", "#00A9FF", : 
  replacement has 8 rows, data has 20
ggplot(G20, aes(area = gdp_mil_usd, fill = hdi, subgroup = hemisphere, 
        subgroup2 = region, subgroup3 = country)) + geom_treemap() + 
  geom_treemap_subgroup3_text(aes(colour = econ_classification))

produces a plot, but the colors are wrong. The text for China, France, United Kingdom, Italy, India, Mexico, Saudi Arabia, Argentina, and Brazil is all the same color even though half of these countries are classified as "Advanced" and half as "Developing".

treemap

System configuration:

> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.1.0    treemapify_2.5.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0            rstudioapi_0.8.0.9000 bindr_0.1.1          
 [4] magrittr_1.5          tidyselect_0.2.5      munsell_0.5.0        
 [7] colorspace_1.3-2      R6_2.3.0              rlang_0.3.0.1        
[10] stringr_1.3.1         plyr_1.8.4            dplyr_0.7.8          
[13] tools_3.5.1           packrat_0.5.0         grid_3.5.1           
[16] gtable_0.2.0          kayadata_0.3.4        withr_2.1.2.9000     
[19] lazyeval_0.2.1        assertthat_0.2.0      tibble_1.4.2         
[22] crayon_1.3.4          bindrcpp_0.2.2        tidyr_0.8.2          
[25] purrr_0.2.5           ggfittext_0.6.0       glue_1.3.0           
[28] stringi_1.2.4         compiler_3.5.1        pillar_1.3.0         
[31] forcats_0.3.0         scales_1.0.0          pkgconfig_2.0.2      

drill down treemap in shiny?

Is there a way to drill down into subgroups with treemaply in shiny ? perhaps by clicking on a tooltip with an html link to observe or tile to expand?

Would this approach work?
https://stackoverflow.com/questions/45021775/use-on-click-for-a-treemapify-object-in-r-shiny

I've seen treemap, on the pokemon dashboard which does support a drilldown
http://jkunst.com/flexdashboard-highcharter-examples/pokemon/

hoping that treemapify would have similar behavior or could be achieved with a click to post back to shiny

Ignoring unknown parameters: radius

I see there is a parameter 'radius', however it didn't work. I need to change the square to rounded corners.How could I do this? Thank you.
ggplot(data=data,mapping = aes(area=Freq,fill=Var1)) +
geom_treemap(start='bottomright',show.legend=F,radius = grid::unit(2, "mm")) @hrbrmstr @wilkox @stijnvanhoey

Error running treemapify with subgroups

See the following reprex: If I render the data frame with treemapify without subgroups it works fine, but if I render it with a subgroup, I get a very unclear error message "Error: i must have one dimension, not 2."

library(tidyverse)
library(treemapify)

nations <- tibble(country=c('USA','Japan','EU','Canada','Australia',
                            'Other Enthusiastic', 'Brazil', 'China','India',
                            'Indonesia','Other Reluctant',
                            'Small Islands', 'Other Vulnerable',
                            'Russia', 'Other Exporters'),
                  type = c(rep_len('Enthusiastic', 6), rep_len('Reluctant',5),
                            rep_len('Vulnerable',2), rep_len('Exporters',2)),
                  emissions = c(17.3, 3.9, 14.2, 2.0, 1.7, 0.6,
                                5.10001, 20.5, 5.4, 1.7, 5.1,
                                0.9, 7.3,
                                6.1, 8.1))

nations <- nations %>%
  mutate(type = ordered(type, levels = c('Enthusiastic', 'Reluctant', 
                                         'Exporters', 'Vulnerable')),
         country = ordered(country, levels = country)) %>%
  arrange(type, desc(emissions), country)

treemapify(nations, area = "emissions")
#> # A tibble: 15 x 6
#>    country            type          ymax  ymin  xmin  xmax
#>    <ord>              <ord>        <dbl> <dbl> <dbl> <dbl>
#>  1 China              Reluctant    0.542 0     0     0.378
#>  2 USA                Enthusiastic 1     0.542 0     0.378
#>  3 EU                 Enthusiastic 0.359 0     0.378 0.774
#>  4 Other Exporters    Exporters    0.359 0     0.774 1    
#>  5 Other Vulnerable   Vulnerable   0.575 0.359 0.378 0.717
#>  6 Russia             Exporters    0.575 0.359 0.717 1    
#>  7 India              Reluctant    0.794 0.575 0.378 0.626
#>  8 Brazil             Reluctant    1     0.794 0.378 0.626
#>  9 Other Reluctant    Reluctant    0.816 0.575 0.626 0.838
#> 10 Japan              Enthusiastic 0.816 0.575 0.838 1    
#> 11 Canada             Enthusiastic 1     0.816 0.626 0.734
#> 12 Australia          Enthusiastic 0.908 0.816 0.734 0.919
#> 13 Indonesia          Reluctant    1     0.908 0.734 0.919
#> 14 Small Islands      Vulnerable   0.926 0.816 0.919 1    
#> 15 Other Enthusiastic Enthusiastic 1     0.926 0.919 1

treemapify(nations, area = "emissions", subgroup = "type")
#> Error: `i` must have one dimension, not 2.

Created on 2020-04-13 by the reprex package (v0.3.0)

Here is my session info. I get the same error with the CRAN version, but I installed the latest GitHub version to be sure the bug hadn't been fixed in the development verion.

> sessionInfo() 
R version 3.6.3 (2020-02-29) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 
Running under: Windows 10 x64 (build 18363)  

Matrix products: default  

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.5.0         stringr_1.4.0         dplyr_0.8.5          
 [4] purrr_0.3.3           readr_1.3.1           tidyr_1.0.2          
 [7] tibble_3.0.0          ggplot2_3.3.0         tidyverse_1.3.0      
[10] treemapify_2.5.3.9001 reprex_0.3.0         

loaded via a namespace (and not attached):
 [1] tidyselect_1.0.0 xfun_0.12        haven_2.2.0      lattice_0.20-41 
 [5] colorspace_1.4-1 vctrs_0.2.4      generics_0.0.2   htmltools_0.4.0 
 [9] rlang_0.4.5      pillar_1.4.3     withr_2.1.2      glue_1.4.0      
[13] DBI_1.1.0        dbplyr_1.4.2     readxl_1.3.1     modelr_0.1.6    
[17] lifecycle_0.2.0  ggfittext_0.8.1  cellranger_1.1.0 munsell_0.5.0   
[21] gtable_0.3.0     rvest_0.3.5      evaluate_0.14    knitr_1.28      
[25] callr_3.4.3      ps_1.3.2         fansi_0.4.1      broom_0.5.5     
[29] Rcpp_1.0.4.6     clipr_0.7.0      backports_1.1.6  scales_1.1.0    
[33] jsonlite_1.6.1   fs_1.4.1         hms_0.5.3        packrat_0.5.0   
[37] digest_0.6.25    stringi_1.4.6    processx_3.4.2   grid_3.6.3      
[41] cli_2.0.2        tools_3.6.3      magrittr_1.5     crayon_1.3.4    
[45] whisker_0.4      pkgconfig_2.0.3  ellipsis_0.3.0   xml2_1.3.1      
[49] lubridate_1.7.8  httr_1.4.1       assertthat_0.2.1 rmarkdown_2.1.2 
[53] rstudioapi_0.11  R6_2.4.1         nlme_3.1-145     compiler_3.6.3 

Treemap text piled up in center in shinyproxy, same code works fine locally on win10

I use treemapify for a small webapp I put together as an internal tool. It works just fine when I run it locally (windows 10 pro) in vscode, rstudio, a browser, or as an internal window to the IDE. When I deploy the exact same code to shinyproxy however I get the below output where all the text just piles up in the center.

Could this be caused by a dependency or system library I've missed in the dockerfile?

this glitch

Wrap text in geom_treemap_text?

Great package. It's always nice to use the familiar grammar of graphics syntax.

I've been doing many treemaps lately using the treemap package. A nice feature of that package is that it will wrap label text onto multiple lines to preserve legibility.

Have you considered adding this as an option for the geom_treemap_text geom? I'll look at the code.

Thanks.

Can tile placement respect factor order?

I'm experimenting with animating a series of treemaps over time, and thought it might be convenient to place the boxes in the order of the factors such that they appear to grow or shrink as appropriate. It's not immediately clear to me how one might do this or if the nature of drawing treemaps is such that the idea is a nonsensical one, but if you have any thoughts on where to try to implement such a change, I would be most interested.

Thank you for all your work on this package; it's a great help.

Error message when "area" aesthetic data contains 0

This is a minor nit, but I spent way longer than I should have troubleshooting the error message.

The code below will recreate the error I experienced:

ggplot(G20, aes(area = gdp_mil_usd, fill = hdi)) +
  geom_treemap()

G20[1, "gdp_mil_usd"] <- 0

ggplot(G20, aes(area = gdp_mil_usd, fill = hdi)) +
  geom_treemap()

Running the last ggplot above will give you the error:

Error in if (aspectRatio > lastAspectRatio) { : 
  missing value where TRUE/FALSE needed

It turns out that I had a 0 value in the data I mapped to the area aesthetic, which led to a 0 or โˆž in the aspectRatio calculation. It might help to add a test to ensure all values of that aesthetic mapping are > 0 and an error message similar to "Data mapped to area aesthetic contains a 0. Please remove rows that contain 0 or choose another area variable.".

Just a suggestion - thanks for creating this great package.

Subgroup geom overlay is misaligned for big plot

Really nice package. I'm finding for a big plot the subgroup geoms are not aligning with the items they contain. E.g.

x = readr::read_csv('https://gist.githubusercontent.com/geotheory/e0213d3a1886e8775bbc4fe35668982a/raw/af05b4cbdc0d24ddecf4f286c2341852d1d8c5c8/data.csv')

glimpse(x)
Observations: 283
Variables: 3
$ group <chr> "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group 1", "group...
$ item  <chr> "item 2", "item 97", "item 124", "item 156", "item 182", "item 240", "item 241", "item 246", "...
$ value <int> 368, 60, 75, 136, 332, 165, 233, 125, 34, 45, 34, 276, 66, 265, 77, 43, 127, 115, 30, 29, 369,...

ggplot(x, aes(area = value, subgroup = group, fill = group, label = item)) + 
  geom_treemap(size=0, col='white') +
  geom_treemap_text(col='black', alpha='.5') +
  geom_treemap_subgroup_border(col='white') +
  geom_treemap_subgroup_text(col='white') +
  guides(fill=F)

Note the groups in the upper-right do not correspond with the groupings of their intended sub-items. This happens with both CRAN and github versions of treemapify. Any ideas how to work around?

image

Passing variables to subgroup doesn't work

I currently develop an R package depending on treemaplify and some functionality broke due to changes in f29b143. Now I'm trying to rewrite the functionality with the new (group, subgroup) interface and ran into an issue which seems like a bug to me. When I save a column to a string variable and pass that variable to the subgroup argument of treemapify, I get an error

treemapify(mtcars, area = "wt", subgroup = "am")
#> expected output of size 32 x 14

am_string <- "am"
treemapify(mtcars, area = "wt", subgroup = am_string)
#> Error in `[.default`(data, subgroups[[1]]) : 
#>   invalid subscript type 'symbol'

Color aesthetics not showing up in legend?

I'm having some trouble getting the color aesthetic to show up in the legend. Working with the G20 example:

`ggplot2::ggplot(G20, ggplot2::aes(area = gdp_mil_usd, fill = region)) +
geom_treemap()

works just fine`

1

ggplot(G20, ggplot2::aes(area = gdp_mil_usd, fill = region, color = econ_classification)) +
geom_treemap() +
scale_color_manual(values = c("red", "black"))

color does not show up in the legend

color and fill

ggplot(G20, ggplot2::aes(area = gdp_mil_usd, fill = region, color = econ_classification, linetype = econ_classification)) +
geom_treemap() +
scale_color_manual(values = c("red", "black")) +
scale_linetype_manual(values = c(1,3)) +
guides(color = guide_legend(override.aes = list(color = c("red", "black"))))

fill shows up in a legend, along with linetype, but color does not`

color fill linetype

Line break?

Dear wilkox,
is it possible to allow line breaks for the text inside the boxes? By default, if a label is to long, the box simply stays empty. Even when the label contains of several words which could be split into several lines easily.
Best
Christian

Can't download successfully

install_github('wilkox/ggfittext')
Downloading GitHub repo wilkox/ggfittext@master
from URL https://api.github.com/repos/wilkox/ggfittext/zipball/master
Installing ggfittext
"C:/PROGRA~1/R/R-3.4.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "C:/Users/Fisher
Pang/AppData/Local/Temp/RtmpQFpfSo/devtools32002db32240/wilkox-ggfittext-d3646e4" --library="C:/Users/Fisher Pang/Documents/R/win-library/3.4" --install-tests

  • installing source package 'ggfittext' ...
    ** R
    Error in parse(outFile) : invalid multibyte character in parser at line 157
    ERROR: unable to collate and parse R files for package 'ggfittext'
  • removing 'C:/Users/Fisher Pang/Documents/R/win-library/3.4/ggfittext'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.