1 year ago
#328429
Toy L
Is it Possible creating a Legend for non grouped data?
I want to obtain a plot that has a legend. In this legend, it shows the names n
, and m
which are in the dfR
and their associated color. However, I have noticed this works only with groups, which is the case for the iris
data set. I could be wrong, which is why I am here.
Any help would be appreciated!
# package:
library(tidyverse)
#df:
dfR<-data.frame(h=rnorm(n=5,mean=4,sd=3),
m=rnorm(n=5,mean=19,sd=10),
Z=rnorm(n=5,mean=9,sd=6))
#Plot:
p<-ggplot(data=dfR, aes(x=h))+
labs(title="Title",
subtitle="Subtitle",
caption="Run number")+
geom_line(aes(y=m),color="red")+
geom_line(aes(y=Z),color="purple")
r
ggplot2
legend-properties
0 Answers
Your Answer