r - ggplot change heatmap for xvalues exactlys -


in image heatmap , want put specific data, years: 2014,2015,2016, different colors, want change name of ylab do, , how add title. thank in advance.

the code used this:  

ggplot(tlm, aes (month, temp)) + geom_line(aes(group = year, color = year)) 

enter image description here

my database distributed well:

enter image description here

with chart g <- ggplot(tlm, aes (month, temp)) + geom_line(aes(group = year, color = year))

to add title:

g <- g + ggtitle("my heatmap title") 

you can use labs(title = "my title"). link shows if need tricks use \n split long titles on 2 lines.

note new ggplot2 has features add captions , on.

change ylabel

use ylab this. let assume want temperature (celsius) not temp

 g <- g + ylab("temperature (celsius)") 

change wording on top of legend

lets wanted change ano year english publication

g <- g + labs(color = "year") 

example code in full

so putting on subset of data, this:

example plot of temp

library(ggplot2) library(data.table)  mydata <- data.table(ano = c("2015", "2015", "2016", "2016"),                      mes = c("enero", "febrero", "enero", "febrero"),                      temp = c(18.17, 18.63, 20.66, 21.1))  #> mydata #    ano     mes  temp #1: 2015   enero 18.17 #2: 2015 febrero 18.63 #3: 2016   enero 20.66 #4: 2016 febrero 21.10  #ggplot(tlm, aes (month, temp)) + geom_line(aes(group = year, color = year)) g <- ggplot(mydata, aes (mes, temp)) + geom_line(aes(group = ano, color = ano))  # splitting illustrative purposes #  can in 1 step ggplot + ggtitle + ylab etc. # title g <- g + ggtitle("my heatmap title")   # ylab g <- g + ylab("temperature (celsius)")  # legend g <- g + labs(color = "year")  #plot chart print(g) 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -