Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading