I have a matrix and want to plot vertical error bars of the interquartile range and mean by column from the matrix. How do I do this in R especially ggplot2, please? A sample matrix is given below:
##Create matrix
B = matrix (c(2,4,3,1,5,7,5,3,8,3,7,3),nrow=4,ncol=3)
##Create zoo object
B2<-as.zoo(B)
colnames(B2)<- c("A","B","C")
B2
A B C
2 5 8
4 7 3
3 5 7
1 3 3
##The Dates for the columns:
Date<-as.yearmon (seq(as.Date("2000/1/1"), by = "month", length.out = 3))
I want a time series plot but with a row based vertical IQR error bar for each timestamp. Here's a sample of the outcome I am trying to achieve' However, rather than have towns on the x-axis, I will have the row id or date.
I had to go the long way round with this so here's what I did (Using the 25% and 75% percentile):
Here's the result with the time series line connecting the mean for each month:
I won't mind an easier way of doing this if there are any ideas.