Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

Examine the four different phases in the typical business cycle.

Answered: 1 week ago