【问题标题】:Why do some waffle chart glyphs work but not others?为什么有些华夫饼图字形有效,而其他字形无效?
【发布时间】:2020-11-12 21:31:22
【问题描述】:

我已经在我的本地机器上安装了 fontawesome ttfs 并将它们加载到 R 中。当我使用 fonts()[grep("Awesome", fonts())] 测试它时,它会按预期返回 "FontAwesome"。

我可以运行带有某些字形的华夫饼图...到目前为止,男性、女性和公文包都可以使用,但其他的则不行,例如“建筑”。

知道发生了什么吗?

library(ggplot2)
library(fontawesome)
library(extrafont)
library(waffle)

# This works fine
waffle(
  c(`Poor=10` =10, `Average=18` = 18, `Excellent=7` =7), rows = 5, colors = c("#FD6F6F", "#93FB98", "#D5D9DD"),
  use_glyph = "female", glyph_size = 12 ,title = 'Girls Performance', legend_pos="bottom"
)

# This does not work
waffle(
  c(`Poor=10` =10, `Average=18` = 18, `Excellent=7` =7), rows = 5, colors = c("#FD6F6F", "#93FB98", "#D5D9DD"),
  use_glyph = "building", glyph_size = 12 ,title = 'Girls Performance', legend_pos="bottom"
)

【问题讨论】:

标签: r font-awesome waffle-chart


【解决方案1】:

不确定为什么某些字形会发生这种情况,但其他字形不会,但我最近遇到了同样的问题。在这里找到了一个很好的方法:https://www.listendata.com/2019/06/create-infographics-with-r.html

听起来您已经有了可用的字体,因此可以跳过操作方法的第一部分,并且您可能只是缺少软件包。您需要添加另外两个:echarts4r(在 CRAN 上)和 echarts4r.assets(目前仅在 github 上)

require(devtools)
devtools::install_github("JohnCoene/echarts4r.assets")
library(tidyverse)
library(waffle)
library(extrafont)
library(echarts4r.assets)
library(echarts4r)

# Works for me with all of these packages loaded
waffle(
  c(`Poor=10` =10, `Average=18` = 18, `Excellent=7` =7), rows = 5, colors = c("#FD6F6F", "#93FB98", "#D5D9DD"),
  use_glyph = "building", glyph_size = 12 ,title = 'Girls Performance', legend_pos="bottom"
)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-11
    • 2017-05-14
    • 1970-01-01
    • 2020-02-23
    • 1970-01-01
    相关资源
    最近更新 更多