r - 如何生成窄ggplot图
问题描述
我必须关注数据
conv.lan_graph_data <- structure(list(`Spoken Languages` = c("Arabic", "Cantonese",
"English", "French", "German", "Hindi", "Japanese", "Korean",
"Mandarin", "Other", "Persian / Farsi", "Prefer not to answer",
"Punjabi", "Russian", "Spanish", "Tagalog", "Urdu", "Vietnamese"
), n = c(7L, 45L, 191L, 2L, 1L, 3L, 3L, 29L, 98L, 15L, 26L, 6L,
13L, 7L, 7L, 10L, 5L, 4L), conv_lang = structure(c(8L, 16L, 18L,
2L, 1L, 3L, 4L, 15L, 17L, 13L, 14L, 7L, 12L, 9L, 10L, 11L, 6L,
5L), .Label = c("German", "French", "Hindi", "Japanese", "Vietnamese",
"Urdu", "Prefer not to answer", "Arabic", "Russian", "Spanish",
"Tagalog", "Punjabi", "Other", "Persian / Farsi", "Korean", "Cantonese",
"Mandarin", "English", "Indigenous languages"), class = "factor")), row.names = c(NA,
-18L), groups = structure(list(`Spoken Languages` = c("Arabic",
"Cantonese", "English", "French", "German", "Hindi", "Japanese",
"Korean", "Mandarin", "Other", "Persian / Farsi", "Prefer not to answer",
"Punjabi", "Russian", "Spanish", "Tagalog", "Urdu", "Vietnamese"
), .rows = list(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L)), row.names = c(NA, -18L
), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
我不会绘制一个类似于进度报告的非常窄的图表
conv.lan_graph_data %>% mutate( Percent = paste0(round(n/sum(conv.lan_graph_data$n)*100,1),"%")) %>% ungroup() %>%
ggplot() +
aes(y = "", x = n, fill = conv_lang, label=Percent) +
geom_col(position="fill", width = 0.1) +
scale_x_continuous(labels = scales::percent_format(accuracy = 1),
expand = c(0, 0),
breaks = seq(0, 1, by = 0.10)) +
scale_y_discrete(expand=c(0,0)) +
theme(axis.title.y=element_blank(),
axis.title.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
theme(legend.position = "none")
但是,我制作的图很宽,我想让它变窄。我尝试使用 c oord_fixed but I don't get the desired outcome
。
在降价块中设置绘图大小也不是一个选项,因为我使用另一个图表来绘制之后
解决方案
推荐阅读
- r - 如何用ggplot填充geom_line()图下的区域?
- isabelle - 伊莎贝尔/霍尔 - 电路
- java - Java中深度嵌套的哈希图
- kubernetes - 如何从 kubernetes master 访问 etcd 集群端点
- web - 在 IIS 中无法使用端口号访问域名
- r - 在r中按名称和条件合并文件
- django - 在 ModelChoiceField 中添加多个标签 - Django
- javascript - flyTo() Leaflet - 我如何使用 onclick 监听器在我的地图上飞行
- node.js - 从 lambda 函数调用 Spotify API
- c# - C# 重命名 JSON 动态属性名