Home > Mobile >  How to change axis values' format to percent in R base plot
How to change axis values' format to percent in R base plot

Time:10-29

I'm trying to change the format of y axis in R base plot i.e. plot(x, y, type='l'). I have y values as numeric and I want values on axis to appear as %. How can I do that?

CodePudding user response:

x <- 1:3
y <- 1:3 / 4
plot(x, y, type = "l")

enter image description here

plot(x, y, type = "l", yaxt = "n")
ylbl <- axTicks(side=2)
ylbl
# [1] 0.3 0.4 0.5 0.6 0.7
axis(2, at = ylbl, labels = paste(100*ylbl, "%"))

enter image description here

  • Related