Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waffle plot come out as empty squares when working in RStudio Notebook (rmarkdown) #67

Open
ManuelSpinola opened this issue Aug 1, 2019 · 4 comments

Comments

@ManuelSpinola
Copy link

When I try the following (see below) example from github from the R console in RStudio, the plot is right, however, I got only empty squares when I try the same example in an RStudio Notebook (rmarkdown).

I am working on MacOS, R 3.6.1, and RStudio 1.2.1564

p1 <- xdf %>%
count(parts, wt = vals) %>%
ggplot(aes(label = parts, values = n)) +
geom_pictogram(n_rows = 10, aes(colour = parts), flip = TRUE, make_proportional = TRUE) +
scale_color_manual(
name = NULL,
values = c("#a40000", "#c68958", "#ae6056"),
labels = c("Fruit", "Sammich", "Pizza")
) +
scale_label_pictogram(
name = NULL,
values = c("apple-alt", "bread-slice", "pizza-slice"),
labels = c("Fruit", "Sammich", "Pizza")
) +
coord_equal() +
theme_ipsum_rc(grid="") +
theme_enhance_waffle() +
theme(legend.key.height = unit(2.25, "line")) +
theme(legend.text = element_text(size = 10, hjust = 0, vjust = 0.75))

@williamlai2
Copy link

Same for me when following the example: https://github.com/hrbrmstr/waffle
Are there any updates on this?

@AJThurston
Copy link

Same on R 4.1.2, R Studio 2022.12.0 Build 353, Windows 10

@rempsyc
Copy link

rempsyc commented Jun 10, 2023

Here is an actual reprex for posteriority:

library(extrafont)
#> Registering fonts with R
grep("Awesome", fonts(), value = TRUE)
#> [1] "Font Awesome 5 Brands Regular" "Font Awesome 5 Free Solid"

library(ggplot2)
library(waffle)
suppressMessages(library(dplyr))

data.frame(
  parts = factor(rep(month.abb[1:3], 3), levels=month.abb[1:3]),
  vals = c(10, 20, 30, 6, 14, 40, 30, 20, 10),
  col = rep(c("blue", "black", "red"), 3),
  fct = c(rep("Thing 1", 3),
          rep("Thing 2", 3),
          rep("Thing 3", 3))
) -> xdf

xdf %>%
  count(parts, wt = vals) %>%
  ggplot(aes(label = parts, values = n)) +
  geom_pictogram(n_rows = 10, aes(colour = parts), flip = TRUE, make_proportional = TRUE) +
  scale_color_manual(
    name = NULL,
    values = c("#a40000", "#c68958", "#ae6056"),
    labels = c("Fruit", "Sammich", "Pizza")
  ) +
  scale_label_pictogram(
    name = NULL,
    values = c("apple-alt", "bread-slice", "pizza-slice"),
    labels = c("Fruit", "Sammich", "Pizza"))
#> Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
#> font family not found in Windows font database

#> Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
#> font family not found in Windows font database

Created on 2023-06-10 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.0 (2023-04-21 ucrt)
#>  os       Windows 10 x64 (build 19045)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_Canada.utf8
#>  ctype    English_Canada.utf8
#>  tz       America/Toronto
#>  date     2023-06-10
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version date (UTC) lib source
#>  cli            3.6.1   2023-03-23 [1] CRAN (R 4.3.0)
#>  colorspace     2.1-0   2023-01-23 [1] CRAN (R 4.3.0)
#>  curl           5.0.0   2023-01-12 [1] CRAN (R 4.3.0)
#>  digest         0.6.31  2022-12-11 [1] CRAN (R 4.3.0)
#>  dplyr        * 1.1.2   2023-04-20 [1] CRAN (R 4.3.0)
#>  DT             0.28    2023-05-18 [1] CRAN (R 4.3.0)
#>  evaluate       0.21    2023-05-05 [1] CRAN (R 4.3.0)
#>  extrafont    * 0.19    2023-01-18 [1] CRAN (R 4.3.0)
#>  extrafontdb    1.0     2012-06-11 [1] CRAN (R 4.3.0)
#>  fansi          1.0.4   2023-01-22 [1] CRAN (R 4.3.0)
#>  farver         2.1.1   2022-07-06 [1] CRAN (R 4.3.0)
#>  fastmap        1.1.1   2023-02-24 [1] CRAN (R 4.3.0)
#>  fs             1.6.2   2023-04-25 [1] CRAN (R 4.3.0)
#>  generics       0.1.3   2022-07-05 [1] CRAN (R 4.3.0)
#>  ggplot2      * 3.4.2   2023-04-03 [1] CRAN (R 4.3.0)
#>  glue           1.6.2   2022-02-24 [1] CRAN (R 4.3.0)
#>  gridExtra      2.3     2017-09-09 [1] CRAN (R 4.3.0)
#>  gtable         0.3.3   2023-03-21 [1] CRAN (R 4.3.0)
#>  highr          0.10    2022-12-22 [1] CRAN (R 4.3.0)
#>  htmltools      0.5.5   2023-03-23 [1] CRAN (R 4.3.0)
#>  htmlwidgets    1.6.2   2023-03-17 [1] CRAN (R 4.3.0)
#>  knitr          1.43    2023-05-25 [1] CRAN (R 4.3.0)
#>  labeling       0.4.2   2020-10-20 [1] CRAN (R 4.3.0)
#>  lifecycle      1.0.3   2022-10-07 [1] CRAN (R 4.3.0)
#>  magrittr       2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
#>  munsell        0.5.0   2018-06-12 [1] CRAN (R 4.3.0)
#>  pillar         1.9.0   2023-03-22 [1] CRAN (R 4.3.0)
#>  pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.3.0)
#>  plyr           1.8.8   2022-11-11 [1] CRAN (R 4.3.0)
#>  purrr          1.0.1   2023-01-10 [1] CRAN (R 4.3.0)
#>  R.cache        0.16.0  2022-07-21 [1] CRAN (R 4.3.0)
#>  R.methodsS3    1.8.2   2022-06-13 [1] CRAN (R 4.3.0)
#>  R.oo           1.25.0  2022-06-12 [1] CRAN (R 4.3.0)
#>  R.utils        2.12.2  2022-11-11 [1] CRAN (R 4.3.0)
#>  R6             2.5.1   2021-08-19 [1] CRAN (R 4.3.0)
#>  RColorBrewer   1.1-3   2022-04-03 [1] CRAN (R 4.3.0)
#>  Rcpp           1.0.10  2023-01-22 [1] CRAN (R 4.3.0)
#>  reprex         2.0.2   2022-08-17 [1] CRAN (R 4.3.0)
#>  rlang          1.1.1   2023-04-28 [1] CRAN (R 4.3.0)
#>  rmarkdown      2.22    2023-06-01 [1] CRAN (R 4.3.0)
#>  rstudioapi     0.14    2022-08-22 [1] CRAN (R 4.3.0)
#>  Rttf2pt1       1.3.12  2023-01-22 [1] CRAN (R 4.3.0)
#>  scales         1.2.1   2022-08-20 [1] CRAN (R 4.3.0)
#>  sessioninfo    1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
#>  stringi        1.7.12  2023-01-11 [1] CRAN (R 4.3.0)
#>  stringr        1.5.0   2022-12-02 [1] CRAN (R 4.3.0)
#>  styler         1.9.1   2023-03-04 [1] CRAN (R 4.3.0)
#>  tibble         3.2.1   2023-03-20 [1] CRAN (R 4.3.0)
#>  tidyselect     1.2.0   2022-10-10 [1] CRAN (R 4.3.0)
#>  utf8           1.2.3   2023-01-31 [1] CRAN (R 4.3.0)
#>  vctrs          0.6.2   2023-04-19 [1] CRAN (R 4.3.0)
#>  waffle       * 1.0.1   2023-06-04 [1] Github (hrbrmstr/waffle@3f61463)
#>  withr          2.5.0   2022-03-03 [1] CRAN (R 4.3.0)
#>  xfun           0.39    2023-04-20 [1] CRAN (R 4.3.0)
#>  xml2           1.3.4   2023-04-27 [1] CRAN (R 4.3.0)
#>  yaml           2.3.7   2023-01-23 [1] CRAN (R 4.3.0)
#> 
#>  [1] C:/Users/there/AppData/Local/R/win-library/4.3
#>  [2] C:/Program Files/R/R-4.3.0/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@rempsyc
Copy link

rempsyc commented Jun 11, 2023

The following seems to be working:

library(ggplot2)
library(emojifont)
library(ggwaffle)

waffle_data <- waffle_iron(iris, aes_d(group = Species)) 

set.seed(100)
waffle_data$label = rep(fontawesome(sample_fontawesome(3)), each = 50)
ggplot(waffle_data, aes(x, y, colour = group)) + 
  geom_text(aes(label=label), family='fontawesome-webfont', size=5) +
  coord_equal() + 
  scale_colour_waffle() + 
  theme_waffle()  

Created on 2023-06-11 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants