Question

Hello this is my code:

datos_tem <- dbGetQuery(connection, paste("SELECT temp_int,hum_int,datetime FROM datalog_v2 WHERE host_id=69 and datetime>='2013-10-01 00:00:00' and datetime<='2013-10-01 23:59:00';", sep=""))
dbDisconnect(connection)

datos_tem$datetime <- as.POSIXct(datos_tem$datetime)
datos_tem$temp_int <- as.numeric(datos_tem$temp_int)
datos_tem$hum_int <- as.numeric(datos_tem$hum_int)


#gg <- qplot(datos_tem$datetime, datos_tem$temp_int) + geom_line()        # first line
#gg <- gg + geom_line(aes( x=datos_tem$datetime, y=datos_tem$hum_int )) # add the second line!

Molten <- melt(datos_tem, id.vars = "datetime")
print(Molten)
ggplot(Molten, aes(x = datetime, y = value, colour = variable)) + geom_line() +
  scale_y_continuous(limits=c(0, 100)) +
   xlab("Time") +
   ylab("Temperature")+ 
  scale_color_manual(values=c("#FF0000", "#0000FF"))+
  opts(panel.background = theme_rect(fill='white'))+
  geom_line(size=1.9)

And produce:

enter image description here

But I have tried a hundred of things to change Legend name and legend name values (temp_int and hum_int must be changed to "Temperature" and "Humidity" and variable lengend name by "Medidas").

Thanks in advance!

Was it helpful?

Solution

Try the following:

+ scale_color_manual(values=c("#FF0000", "#0000FF"), 
                   name="Medidas",
                   labels=c("Temperature", "Humidity"))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top