0
votes

I have a plot made with forestplot in the rmeta package. Notice the horizontal axis has no tick marks and labels between 0.2 and 7. How could I add tick marks without labels at 1,2,3,4,5 and 6 without labelling them? I just want the tick marks here. Here is the plot: enter image description here

How do I have the ticks at 0.2,1,2,3,4,5,6 and 7, but I labelled only at c(0.2,7)? This the code:

library(rmeta)
tabletext<-rbind(c("A","3.77"),
             c("B","1.33"),
             c("C","1.32"),
             c("D","1.12"),
             c("E","1.58"),
             c("F","0.9"))
m=c(3.77,1.33,1.32,1.12,1.58,0.9)
l=c(0.6144,0.644,0.6536,0.4536,1.0116,0.7236)
u=c(6.9256,2.016,1.9864,1.7864,2.1484,1.0764)
#overview datafile:
cbind(tabletext, m,l,u)
                       m      l        u       
[1,] "A"         "3.77" "3.77" "0.6144" "6.9256"
[2,] "B"         "1.33" "1.33" "0.644"  "2.016" 
[3,] "C"         "1.32" "1.32" "0.6536" "1.9864"
[4,] "D"         "1.12" "1.12" "0.4536" "1.7864"
[5,] "E"         "1.58" "1.58" "1.0116" "2.1484"
[6,] "F"         "0.9"  "0.9"  "0.7236" "1.0764"
forestplot(tabletext,m,l,u, zero=1, xticks=c(0.2,7),col=meta.colors(box="royalblue",line="darkblue", summary="royalblue"))

I could extend the xticks=c(0.2,7) to xticks=c(0.2,1,2,3,4,5,6,7), but then all the labels at 2,3,4,5,6 would also be printed, which I dont want to.

1
Instead of Forest1 <- read.table(file="Forest_1.txt", sep="\t", head=TRUE, row.names=1) , which helps no one, you should give the result of dput(Forest1) to make your code reproducible. - ziggystar
thank you ziggystar, I adjusted the code to be ready for a copy and paste in windows R. - user3219379

1 Answers

0
votes

Thanks for the suggestion. The rmeta does not have this option but I've added this to the forestplot-package (currently in the develop branch 1.2.1):

tabletext<-rbind(c("A","3.77"),
                 c("B","1.33"),
                 c("C","1.32"),
                 c("D","1.12"),
                 c("E","1.58"),
                 c("F","0.9"))
m=c(3.77,1.33,1.32,1.12,1.58,0.9)
l=c(0.6144,0.644,0.6536,0.4536,1.0116,0.7236)
u=c(6.9256,2.016,1.9864,1.7864,2.1484,1.0764)

#overview datafile:
xticks <- seq(from = 0.2, to = 7, by = .5)
xlabels <- rep(TRUE, length.out = length(xticks))
xlabels[xticks > 2] <- FALSE
xlabels[length(xlabels)] <- TRUE
attr(xticks, "labels") <- xlabels
forestplot(tabletext,new_page = TRUE,
           m,l,u, 
           zero=1, 
           xticks=xticks,
           col=fpColors(box="royalblue",line="darkblue", summary="royalblue"))

enter image description here

Download the develop version using devtools:

devtools::install_github("gforge/forestplot", ref="develop")