Last active
December 15, 2015 00:39
-
-
Save dmarcelinobr/5174735 to your computer and use it in GitHub Desktop.
Example on how to manipulate axis values in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fake data | |
y<- sample(10, 100, rep=T) | |
x <- rnorm(100) | |
# plots | |
par(mfrow=c(2,3)) # open an object | |
plot(x,y) # First plot | |
title("Default plot") | |
plot(x,y, axes = FALSE) # Second plot | |
title("Without any axis") | |
plot(x,y, axes = FALSE) # Third plot | |
axis(1) | |
title("X-axis added, but as is") | |
plot(x,y, axes = FALSE) # Fourth plot | |
axis(2) | |
title("Y-axis added, but as is") | |
yticks <- seq(5, 12, 1) | |
plot(x,y, axes = FALSE) # Fifth plot | |
axis(2, at = yticks, labels = yticks, col.axis="red", las=2) | |
title("Manipulated Y-axis") | |
xticks <- seq(0, 3, .5) | |
plot(x,y, axes = FALSE) # Sixth plot | |
axis(2, at = yticks, labels = yticks, col.axis="red", las=2) | |
axis(1, at = xticks, labels = xticks, col.axis="blue", las=2, tck=-.01) | |
title("Manipulated Y and X axes") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment