简体   繁体   English

如何使用ggplot更改R中图形上的颜色代码标签?

[英]How to change the color code label on a graph in R using ggplot?

I'm doing a case study, and I wanted to include some stuff made in R to practice my coding skills on that language. 我正在做一个案例研究,我想包括一些用R语言编写的东西,以练习我在该语言上的编码技能。

According to my notes, I should be able to change the color code label with the scale_colour_manual(name = "Region") part, but on the graph it just don't make the change. 根据我的注释,我应该能够使用scale_colour_manual(name = "Region")部分更改颜色代码标签,但是在图形上只是不进行更改。

Any ideas? 有任何想法吗?

在此处输入图片说明

In general, ggplot uses colour when referring to outlines, and fill when referring to the inside colour of a shape. 通常, ggplot在引用轮廓时使用colour ,而在引用形状的内部颜色时使用fill In your example the colour of the plots is actually a fill . 在您的示例中,图的颜色实际上是fill So you should be using 所以你应该使用

scale_fill_manual(name = "Region")

That should then do what you want it to. 那应该做你想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM