##########Import your file####################################
> setwd("/home/rajiv/for_1695_datast_confidential/04_weather")
> ec1w <- read.csv("ec1_weather_data.csv", header = TRUE, sep = ",")
> head(ec1w)
###Convert date to as date with column "Date"
> ec1w$Date <- as.Date(ec1w$date)
############How to plot graph in ggplot2######################
1. > install.packages("ggplot2")
> library('ggplot2')
###plotting graph with ggplot2
> ggplot2(ec4w)+
geom_line(aes(x=Date, y=pr))
2. > install.packages("gtidyverse")
> library('tidyverse')
3. > install.packages("ggpubr",
repos = c("https://cran.rediris.org/", "https://cloud.r-project.org/"),
dependencies = TRUE)
> library('ggpubr)
##############ploting with ggarrange
> ec1 <- ggplot2(dataframe1)+
geom_line(aes(x=Date, y=at))+
geom_col(aes(x=Date, y=pr), color = "red")
> ec2 <- ggplot2(dataframe2)+
geom_line(aes(x=Date, y=at))+
geom_col(aes(x=Date, y=pr), color = "red")
> ec3 <- ggplot2(dataframe3)+
geom_line(aes(x=Date, y=at))+
geom_col(aes(x=Date, y=pr), color = "red")
> ggpubr::ggarrange(ec1, ec2, ec3,
ncol = 1, nrow = 3)
#################Plotting with common axis with ggarrange
> library(grid)
> library(gridExtra)
> ec111 <- ggpubr::ggarrange(ec1 + rremove("ylab") + rremove("xlab"),
ec2 + rremove("ylab") + rremove("xlab"),
ec3 + rremove("ylab") + rremove("xlab"),
labels = c("EC1",
"EC2",
"EC3"),
ncol = 1,
nrow = 3,
hjust = -15,
common.legend = TRUE,
legend = "bottom",
align = "hv",
font.label = list(size = 10, color = "black", face = "bold", family = NULL, position = "top"))
then,
> annotate_figure(ec111, left = textGrob("Temperature (black) and Precipitation (red)", rot = 90, vjust = 1, gp = gpar(cex = 1.3)),
bottom = textGrob("Date", gp = gpar(cex = 1.3)))