Question
I am using R for graphs. I want to change the color of the line being graphed based upon a variable in the data frame.
I am using R for graphs. I want to change the color of the line being graphed based upon a variable in the data frame. Can you help or make a suggestion please? I am including my code.Thank you.
MaryMarion
theme_minimal() + theme(legend.position = "right") ) library(ggplot2) require(scales) theme_set(
myplot1 <- ggplot(data=df,aes(x=df$Snowfall.R,y=df$Snowfall.B), shape=df$att, color=as.factor(df$att))+ geom_line()+ geom_point()+ geom_smooth(method='lm', col="grey75")+ labs(x = "Snowfall,Rochester(in)", y = "Snowfall,Buffalo(in)") + ggtitle("Buffalo vs Rochester")+ expand_limits(y=0)+ coord_fixed(ratio=1/3)+ scale_color_manual(1="blue", 2="red")+ scale_x_continuous(limits=c(0,230),breaks=c(50,100,150,200))+ scale_y_continuous(limits=c(0,230),breaks=c(50,100,150,200)) myplot1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started