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)) my database distributed well:
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:
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
Post a Comment