rstudio / thematic

Theme ggplot2, lattice, and base graphics based on a few simple settings.
https://rstudio.github.io/thematic/
Other
244 stars 10 forks source link

Theme element `combmatrix.label.make_space` is not defined in the element hierarchy. #110

Open biomystery opened 2 years ago

biomystery commented 2 years ago

Describe the problem

The following shiny app will produce an error message

ERROR: Theme element `combmatrix.label.make_space` is not defined in the element hierarchy.

But if comment out thematic_shiny(font = "auto"). The app can run without no problem.

The theme element is defined in https://github.com/const-ae/ggupset/blob/ae2cc9287eb0cdd613b1d6cd6b8776435b287997/R/theme_combmatrix.R.

#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

library(shiny)
library(ggplot2)
library(ggupset)
library(thematic)
library(tidyverse, warn.conflicts = FALSE)

thematic_shiny(font = "auto")

# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("Old Faithful Geyser Data"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            sliderInput("bins",
                        "Number of bins:",
                        min = 1,
                        max = 50,
                        value = 30)
        ),

        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot")
        )
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
      tidy_movies %>%
        distinct(title, year, length, .keep_all=TRUE) %>%
        ggplot(aes(x=Genres)) +
        geom_bar() +
        ggupset::scale_x_upset(n_intersections = 20)
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

Session Info


R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] forcats_0.5.1    stringr_1.4.0    dplyr_1.0.7      purrr_0.3.4      readr_2.0.2      tidyr_1.1.4     
 [7] tibble_3.1.5     tidyverse_1.3.1  thematic_0.1.2.1 ggupset_0.3.0    ggplot2_3.3.5    shiny_1.7.1     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7       lubridate_1.8.0  lattice_0.20-44  assertthat_0.2.1 digest_0.6.28    utf8_1.2.2      
 [7] mime_0.12        R6_2.5.1         cellranger_1.1.0 backports_1.2.1  reprex_2.0.1     httr_1.4.2      
[13] pillar_1.6.3     rlang_0.4.11     readxl_1.3.1     rstudioapi_0.13  jquerylib_0.1.4  labeling_0.4.2  
[19] munsell_0.5.0    broom_0.7.9      compiler_4.1.1   httpuv_1.6.3     modelr_0.1.8     xfun_0.26       
[25] pkgconfig_2.0.3  htmltools_0.5.2  tidyselect_1.1.1 fansi_0.5.0      crayon_1.4.1     tzdb_0.1.2      
[31] dbplyr_2.1.1     withr_2.4.2      later_1.3.0      grid_4.1.1       jsonlite_1.7.2   xtable_1.8-4    
[37] gtable_0.3.0     lifecycle_1.0.1  DBI_1.1.1        magrittr_2.0.1   scales_1.1.1     cli_3.0.1       
[43] stringi_1.7.5    cachem_1.0.6     farver_2.1.0     fs_1.5.0         promises_1.2.0.1 xml2_1.3.2      
[49] bslib_0.3.1      ellipsis_0.3.2   generics_0.1.0   vctrs_0.3.8      tools_4.1.1      glue_1.4.2      
[55] hms_1.1.1        fastmap_1.1.0    colorspace_2.0-2 rvest_1.0.1      knitr_1.36       haven_2.4.3     
[61] sass_0.4.0 
biomystery commented 2 years ago

seems that thematic made the original ggplot2:::validate_element not work properly in this case

https://github.com/tidyverse/ggplot2/blob/87e9b85dd9f2a294f339d88a353d0c11c851489d/R/theme-elements.r#L511

AideenMcI commented 6 months ago

Has there been a resolution for this issue? I'm running in to the same problem.