I'd like to change the label in the legend in Rggplot2scale_fill_discrete
We were able to change the legend label by referring to the page above.
In addition to this, how do I perform color specification?
library(ggplot2)
legend.labels<-c("hoge", "fuga", "piyo")
ggplot(iris,aes(Sepal.Length,Petal.Length))+
geom_line(aes(color=Species))+
scale_color_discrete(labels=legend.labels)+
scale_color_manual(values=c("red", "blue", "orange"))
In this script,
Scale for 'colour' is already present. Adding another scale for 'colour',
which will replace the existing scale.
The error message is returned and the color specification is applied, but
Legend labels do not apply.
What code should I use to change the legend label after specifying the color?
I look forward to your kind cooperation.
You can add labels
to the scale_color_manual()
argument.
iris%>%
ggplot(aes(x=Sepal.Length,
y=Petal.Length, color=Species))+
geom_line()+
scale_color_manual(values=c('red','blue','orange'),
labels=c("hoge", "fuga", "piyo"))
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
537 Uncaught (inpromise) Error on Electron: An object could not be cloned
549 PHP ssh2_scp_send fails to send files as intended
709 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.