On attempting to create a waffle chart with pictograms I get the following warning message:
Warning messages:
1: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
2: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
and the output in my plot window is as per the image at the bottom of this post, that is, the plot does not display a waffle chart with pictograms of apples, bread-slices and pizza-slices in this case as opposed to a waffle chart with straight forward squares.
I have spent many hours trying to resolve without success. The pictograms are from FontAwesome 5 FontAwesome5 and they are .otf files. The files Font Awesome 5 Brands Regular and Font Awesome 5 Free appear in my Windows/Fonts folder.
Can anyone tell me why the plot does not show the icons (pizza-slice, bread-slice, and apple-alt) please?
With reference to the short R script:
The call to fa_grep() below is successful in that my viewer shows "apple-alt", "bread-slice", and "pizza-slice". This leads me to believe I have correctly installed the pictograms from Awesome 5 in Windows and made them available to R.
The first call to ggplot correctly produces the waffle chart with colored squares.
The second call to ggplot is were the Warning message occurs. The plot does not show the icons.
# https://www.r-bloggers.com/2019/07/quick-hit-waffle-1-0-font-awesome-5-pictograms-and-more/
library(reprex)
library(waffle)
library(hrbrthemes)
library(extrafont)
library(dplyr)
extrafont::loadfonts(quiet = TRUE)
extrafont::fonttable() %>%
as_tibble() %>%
filter(grepl("Awesom", FamilyName)) %>%
select(afmfile, FullName, FamilyName, FontName)
fa_grep("bread|pizza|apple|pear|peach|lemon|sandwich")
tibble(
food_group = factor(
c("Fruit", "Sandwiches", "Pizza"),
levels=c("Fruit", "Sandwiches", "Pizza")
),
consumption = c(5, 20, 52)
) -> xdf
xdf
ggplot(xdf, aes(fill = food_group, values = consumption)) +
geom_waffle(n_rows = 10, make_proportional = TRUE) +
coord_equal() +
theme_ipsum_rc(grid="") +
theme_enhance_waffle()
ggplot(xdf, aes(label = food_group, values = consumption)) +
geom_pictogram(n_rows = 10, make_proportional = TRUE, color = "black") +
scale_label_pictogram(
name = NULL,
values = c(
Fruit = "apple-alt",
Sandwiches = "bread-slice",
Pizza = "pizza-slice"
)
) +
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))
Session Info()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reprex_0.3.0 dplyr_1.0.2 extrafont_0.17 hrbrthemes_0.8.0 waffle_1.0.1
[6] ggplot2_3.3.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 ps_1.3.0 assertthat_0.2.1 digest_0.6.27
[5] utf8_1.1.4 mime_0.9 R6_2.5.0 plyr_1.8.4
[9] evaluate_0.14 pillar_1.6.0 gdtools_0.2.2 rlang_0.4.10
[13] curl_4.3 rstudioapi_0.10 extrafontdb_1.0 whisker_0.4
[17] callr_3.3.2 DT_0.17 rmarkdown_1.16 labeling_0.3
[21] stringr_1.4.0 htmlwidgets_1.5.1 munsell_0.5.0 shiny_1.4.0
[25] compiler_3.6.0 httpuv_1.5.2 xfun_0.10 pkgconfig_2.0.3
[29] systemfonts_0.3.2 clipr_0.7.0 htmltools_0.5.1.1 tidyselect_1.1.0
[33] tibble_2.1.3 gridExtra_2.3 fansi_0.4.0 crayon_1.3.4
[37] withr_2.1.2 later_1.0.0 grid_3.6.0 jsonlite_1.7.2
[41] xtable_1.8-4 Rttf2pt1_1.3.8 gtable_0.3.0 lifecycle_1.0.0
[45] magrittr_2.0.1 scales_1.1.1 cli_1.1.0 stringi_1.5.3
[49] farver_2.0.3 fs_1.5.0 promises_1.1.0 ellipsis_0.3.0
[53] generics_0.0.2 vctrs_0.3.4 RColorBrewer_1.1-2 tools_3.6.0
[57] glue_1.4.2 purrr_0.3.3 crosstalk_1.0.0 processx_3.4.1
[61] fastmap_1.0.1 yaml_2.2.0 colorspace_1.4-1 knitr_1.25
Warning messages:
1: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
2: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
3: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
4: In grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database