r - Labeller 在 facet_grid 中重构后未应用标签
问题描述
我正在尝试使用 ggplot2 中的 labeller 函数来标记多面图。当我运行我的代码时,如果我尝试在变量的重构中包含标签(即第 5 和第 4 个方面标签未按应有的方式切换),或者标签器似乎不适用,我会得到错误标记的方面如果在重构之外使用新标签,但顺序是正确的。为每种情况附加的图像,以及我试图用作标签的变量。我在这里错过了一步吗?
dnr_names <- c('ND','GD','APD','TTD','MD')
names(dnr_names) <- c(1,2,3,4,5)
D1 <- ggplot(fsom_neurons_meta_norm) +
aes(x = MetaDisease, fill = Meta, weight = meta_n_norm) +
geom_bar(position = "dodge") +
scale_fill_manual(labels = c(1,2,3,4,5,6,7,8,9,10,11), values = color6) +
labs(x = "Cluster types", y = "Cluster proportions (relative to total region)", title = "Neuronal populations across de novo regions", fill = "Cluster") +
scale_x_discrete(labels=c("D", "ND")) +
theme_minimal() +
theme1a +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +#gets rid of lines
facet_grid(cols = vars(factor(de_novo_regions, levels = c(1,2,3,5,4))), labeller = labeller(de_novo_regions = dnr_names))
D1
D1 <- ggplot(fsom_neurons_meta_norm) +
aes(x = MetaDisease, fill = Meta, weight = meta_n_norm) +
geom_bar(position = "dodge") +
scale_fill_manual(labels = c(1,2,3,4,5,6,7,8,9,10,11), values = color6) +
labs(x = "Cluster types", y = "Cluster proportions (relative to total region)", title = "Neuronal populations across de novo regions", fill = "Cluster") +
scale_x_discrete(labels=c("D", "ND")) +
theme_minimal() +
theme1a +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +#gets rid of lines
facet_grid(cols = vars(factor(de_novo_regions, levels = c(1,2,3,5,4), labels = dnr_names)))
D1
解决方案
推荐阅读
- php - 在 SQL 请求中按 meta_value 排序
- c# - SocketAsyncResult.CheckIfThrowDelayedException () System.Net.Sockets.SocketException:Xamarin.Android 应用程序中的网络子系统已关闭
- apache-kafka - 为什么 .timeindex inf kafka 存储相对偏移量而不是日志段的实际位置或相对位置?
- python - 在 pyspark 中将基于 RDD 的 API 代码转换为基于 Dataframe 的 API 代码
- javascript - 将所有 DIV 元素更改为 TABLE、TR、TD 及其属性
- android - 使用 firebase 进行身份验证时出现 java.lang.IllegalArgumentException
- java - 已用时间计算器字符串开关
- oracle - SQL 查询未在数据块 Oracle 表单上显示结果
- java - 有没有办法在 Spring boot 中获取原始的 post body?
- node.js - PM2 - SyntaxError:在严格模式之外尚不支持块范围的声明