r - 为什么有些华夫饼图字形有效,而其他字形无效?
问题描述
我已经在我的本地机器上安装了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"
)
解决方案
不确定为什么某些字形会发生这种情况,但其他字形不会,但我最近遇到了同样的问题。在这里找到了一个很好的方法: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"
)
推荐阅读
- python - 如何提取 Facebook 图像的 URL
- javascript - 使用 json 格式的数据制作 highcharts 图表,带有 4 元素数组
- react-native - 后台返回后调用函数
- python-3.x - 'list' 对象没有属性 'encode
- javascript - 在 TouchableHighlight 标记内包装图像标记无法正常工作
- javascript - 我正在尝试包含 simplepeer.js,但未找到显示 404 错误。相反,我给出了正确的道路
- javascript - 从 Firestore DocumentReferences 列表中获取数据到 State React
- c# - 当我从我的数据库中导入模型时,我希望我的数据库中的实例不在数据库模型中生成
- python - Django 将用户详细信息添加到 UserPost 列表视图
- json - 为令牌交换代码时获取 unsupported_grant_type