hjust in geom_cladelab not working properly
0
0
Entering edit mode
2.7 years ago
Søren • 0

I have an issue with hjust of clade lab when using geom_cladelab. The justification does not change when specifying the labels to align with the outer circle and having angle = "auto" . I have added an reprex of the issue. The problem persists with circular layout and using verbal hjust argument such as "left" or "right". Also the problem is unique to my stationary computer, as the justification works properly on my laptop.

example image

# reprex
library("ggtree")
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)

label_data <- data.frame(node2 = c(1:7), label2 = paste(1:7, c(rep("correct hjust", 3), rep("wrong hjust", 4))))

tree_plot <- 
  ggtree(
    tree, 
    layout = "fan"
  ) +
  geom_cladelab(
    data = label_data, 
    mapping = aes(node = node2, label = label2),
    angle = "auto",
    geom = "text", 
    horizontal = TRUE, 
    align = TRUE, 
    hjust = 1
  )
tree_plot

session info

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

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

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

other attached packages:
[1] ggtree_3.0.3

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7          pillar_1.6.2        compiler_4.1.0      BiocManager_1.30.16
 [5] tools_4.1.0         aplot_0.0.6         jsonlite_1.7.2      tidytree_0.3.4     
 [9] lifecycle_1.0.0     tibble_3.1.2        gtable_0.3.0        nlme_3.1-152       
[13] lattice_0.20-44     pkgconfig_2.0.3     rlang_0.4.11        rstudioapi_0.13    
[17] cli_3.0.1           DBI_1.1.1           rvcheck_0.1.8       patchwork_1.1.1    
[21] parallel_4.1.0      treeio_1.16.2       withr_2.4.2         dplyr_1.0.7        
[25] generics_0.1.0      vctrs_0.3.8         grid_4.1.0          tidyselect_1.1.1   
[29] glue_1.4.2          R6_2.5.1            fansi_0.5.0         sessioninfo_1.1.1  
[33] farver_2.1.0        ggplot2_3.3.5       purrr_0.3.4         tidyr_1.1.3        
[37] magrittr_2.0.1      scales_1.1.1        ellipsis_0.3.2      assertthat_0.2.1   
[41] ape_5.5             colorspace_2.0-2    labeling_0.4.2      utf8_1.2.1         
[45] lazyeval_0.2.2      munsell_0.5.0       crayon_1.4.1  
geom_cladelab R ggtree • 509 views
ADD COMMENT

Login before adding your answer.

Traffic: 2281 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6