R语言ggplot2报错:'mapping' should be created with 'aes()' 解决方法
根据报错信息,问题出在代码中的'aes()'函数调用上。具体地,'aes()'函数中的映射参数应该使用正确的语法来创建,而不是直接使用数据框和列名。
下面是对代码的修改建议:
p2 <- ggplot(GO_function, aes(x = GO_Term, y = all_diff_proteins_num)) +
geom_col(aes(fill = Term_Type), width = 0.5) +
scale_fill_manual(values = c("#8EA1CB", "#67C1A5", "#FA8E61")) +
theme(panel.grid = element_blank(), panel.background = element_rect(color = "black", fill = "transparent")) +
scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
coord_flip()
在上述修改后的代码中,我将'aes()'函数的映射参数移动到了'ggplot()'函数的内部,并通过x = GO_Term和y = all_diff_proteins_num来指定x轴和y轴的映射关系。同时,geom_col()函数的映射参数也使用了正确的语法。
请注意,这只是根据报错信息推测的解决方案。如果问题仍然存在,请提供更多的代码和数据信息,以便我更好地帮助您解决问题。
原文地址: https://www.cveoy.top/t/topic/l4v 著作权归作者所有。请勿转载和采集!