tylermorganwall / rayshader

R Package for 2D and 3D mapping and data visualization
https://www.rayshader.com/
2.03k stars 211 forks source link

3D elevation and color-aesthetics misaligned in plot_gg #224

Open nucleic-acid opened 2 years ago

nucleic-acid commented 2 years ago

When rendering a 3D plot from a ggplot2 object, the rendered columns of the 3D object are not aligned with the actual point aesthetics. Also the legend 3D object and the legend-colors are offset. Here are two angles of the same plot:

plot_gg1 plot_gg2

Minimal example (produces the plot above)

p1 <- ggplot(mtcars) +
  aes(x=wt,
      y = hp,
      color = mpg)+
  geom_point()

rayshader::plot_gg(p1, height_aes = "color" )

The 3D render and the point aesthetics seem to be offset by just a bit, as if they weren't using the same scales.

system info

tylermorganwall commented 2 years ago

I'm not seeing this on my machine—can you post the output of sessionInfo()?

nucleic-acid commented 2 years ago
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C               LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8    LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] ggtext_0.1.1         MetBrewer_0.2.0      rayshader_0.27.4     forcats_0.5.1        stringr_1.4.0       
 [6] dplyr_1.0.8          purrr_0.3.4          readr_2.1.2          tidyr_1.2.0          tibble_3.1.6        
[11] ggplot2_3.3.5        tidyverse_1.3.1      palmerpenguins_0.1.0

loaded via a namespace (and not attached):
 [1] httr_1.4.2         jsonlite_1.8.0     foreach_1.5.2      modelr_0.1.8       assertthat_0.2.1   cellranger_1.1.0  
 [7] progress_1.2.2     lattice_0.20-45    Rttf2pt1_1.3.10    pillar_1.7.0       backports_1.4.1    glue_1.6.2        
[13] extrafontdb_1.0    digest_0.6.29      gridtext_0.1.4     rvest_1.0.2        colorspace_2.0-3   htmltools_0.5.2   
[19] pkgconfig_2.0.3    broom_0.7.12       magick_2.7.3       haven_2.4.3        scales_1.1.1       tzdb_0.3.0        
[25] generics_0.1.2     farver_2.1.0       ellipsis_0.3.2     cachem_1.0.6       withr_2.5.0        hexbin_1.28.2     
[31] cli_3.2.0          magrittr_2.0.3     crayon_1.5.1       readxl_1.4.0       memoise_2.0.1      fs_1.5.2          
[37] fansi_1.0.3        doParallel_1.0.17  xml2_1.3.3         textshaping_0.3.6  tools_4.1.3        prettyunits_1.1.1 
[43] hms_1.1.1          lifecycle_1.0.1    munsell_0.5.0      reprex_2.0.1       compiler_4.1.3     pkgdown_2.0.2     
[49] terrainmeshr_0.1.0 systemfonts_1.0.4  rlang_1.0.2        grid_4.1.3         iterators_1.0.14   rstudioapi_0.13   
[55] htmlwidgets_1.5.4  labeling_0.4.2     gtable_0.3.0       codetools_0.2-18   DBI_1.1.2          markdown_1.1      
[61] R6_2.5.1           lubridate_1.8.0    knitr_1.38         fastmap_1.1.0      extrafont_0.17     utf8_1.2.2        
[67] ragg_1.2.2         stringi_1.7.6      parallel_4.1.3     Rcpp_1.0.8.3       png_0.1-7          vctrs_0.4.0       
[73] rgl_0.108.3        dbplyr_2.1.1       tidyselect_1.1.2   xfun_0.30