Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove 'y' label from plot in R

Tags:

text

plot

r

Does anyone know how to extract the 'y' off the y-axis while preserving the variable names in the following plot:

par(mar = c(5,7,4,2) +.01)
matrix <- matrix(rnorm(100) ,ncol = 2, nrow =6)
y <- 1:6
par(mar = c(5,7,4,2) +.01)
plot(matrix[,1], y, cex = .8, pch = 20, xlab = "Standardized Mean Differences", col = "darkblue",   main = "Balance Assessment", yaxt = "n")
points(matrix[,2], y, cex = .8, pch = 20, col ="cyan")
abline(v = 0, col = "gray50", lty =2)   
text(y =1:6, par("usr")[1], labels = c("Var1", "Var2", "Var3", "Var4", "Var5", "Var6"), pos = 2, xpd = TRUE, srt = 0, cex = .8, font = 1, col = "blue")

It's minor, but it's driving me crazy. Thanks!Plot Below

like image 851
coding_heart Avatar asked May 22 '13 21:05

coding_heart


People also ask

How do you change the Y axis labels in R?

To set labels for X and Y axes in R plot, call plot() function and along with the data to be plot, pass required string values for the X and Y axes labels to the “xlab” and “ylab” parameters respectively. By default X-axis label is set to “x”, and Y-axis label is set to “y”.

How do I remove a boxplot label in R?

If we want to remove the axis labels then axes = FALSE argument can be used. For example, if we have a vector x then the boxplot for x without axes labels can be created by using boxplot(x,axes=FALSE).

How do I remove axis values in R?

In this approach to remove the axis values of the plot, the user just need to use the base function plot() of the R programming language, and further in this function the user needs to use the axt argument of this function and set its value to “n” and this will be leading to the removal of the Axis Values of Plot in R ...

How do you change axis labels in R studio?

To alter the labels on the axis, add the code +labs(y= "y axis name", x = "x axis name") to your line of basic ggplot code. Note: You can also use +labs(title = "Title") which is equivalent to ggtitle .


1 Answers

Just set ylab='' to remove it.

like image 153
Jilber Urbina Avatar answered Oct 03 '22 05:10

Jilber Urbina