barplot y Axis Ticks - waterfall plot

data.frame(
   row.names = c("9","8","7","3","6","13","14","12",
                 "5","11","1","2","4","10"),
   patientid = c(9, 8, 7, 3, 6, 13, 14, 12, 5, 11, 1, 2, 4, 10),
      change = c(45, 23, 20, 15, 15, 0, 0, -5, -15, -15, -20, -20, -20, -66)

Above is my code for dataframe - Waterfall_plot

I enter the following to get a nice waterfall plot

o <- order(Waterfall_plot$change, decreasing=TRUE,na.last=NA)
Waterfall_plot <- Waterfall_plot[o,]


barplot(Waterfall_plot$change, col="blue", border="blue", space=0.5, ylim=c(-100,100), main = "Waterfall plot for changes in QoL scores", ylab="Change  in tumour size (%)", cex.axis=1.2, cex.lab=1.4)

To give me a nice waterfall plot. However, I want the ticks to be -100, - 75, - 50, - 25, 0 , 25, 50, 75, 100, rather than the current -100, -50, 0, 50, 100. I am unable to do this. Can someone please help?

Many thanks

Here is how I would do it. I adjusted cex.axis so that all the tick labels would appear on my screen. You may want to adjust that.

Waterfall_plot <- data.frame(
  row.names = c("9","8","7","3","6","13","14","12",
                "5","11","1","2","4","10"),
  patientid = c(9, 8, 7, 3, 6, 13, 14, 12, 5, 11, 1, 2, 4, 10),
  change = c(45, 23, 20, 15, 15, 0, 0, -5, -15, -15, -20, -20, -20, -66))

o <- order(Waterfall_plot$change, decreasing=TRUE,na.last=NA)
Waterfall_plot <- Waterfall_plot[o,]


barplot(Waterfall_plot$change, col="blue", border="blue", 
        space=0.5, ylim=c(-100,100), 
        main = "Waterfall plot for changes in QoL scores", 
        ylab="Change  in tumour size (%)", cex.axis=1.2, cex.lab=1.4,
        axes = FALSE)  
axis(side = 2, at = seq(-100,100,25),cex.axis = 0.8)

Created on 2022-02-17 by the reprex package (v2.0.1)

Many thanks. This Solution worked really well for my waterfall plot.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.