We can set up the initial graphing syntax as an object. In the next example, we call this object Y
. We can use any object name, as long as it starts with an alphabetic character. We map the symbol color
to ETH
, a categorical variable of three levels. Then, we impose our own colors by adding the new colors as a layer to the object Y
:
Y <- qplot(HEIGHT, WEIGHT_1, data = T, main = "HEIGHT vs. WEIGHT", xlab = "HEIGHT (cm)", ylab = "WEIGHT BEFORE TREATMENT (kg)" , geom = "point" , color = factor(ETH), size = 2, alpha = I(0.7)) Y + scale_color_manual(values = c("darkgreen","red", "yellow"))
Setting up graphs as objects can be very useful. Using your initial object, you can try out different color schemes, symbol types, and other attributes until you get the appearance you want.