Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide x-axis in lattice R

Tags:

r

lattice

How to hide x-axis (xlim?) in lattice xyplot?

Normally with plot that would be:

hist(rnorm(10,0,2), axes=F)

And also global solution would be great, since I have quite few plots. I'm using the gridExtra package:

grid.arrange(plot1,plot2,plot3, ncol=3)

This for instance allows to hide xlab, ylab, main.

pl = list(plot1,plot2,plot3)
do.call(grid.arrange, lapply(pl, update, xlab="", ylab="", main=""))

Sample data just in case:

Data <- data.frame(x=rnorm(10,2,2),y=rnorm(10,3,3),z=rexp(10,2))
plot1 <- xyplot(x~y, Data, xlab="name", ylab="name", main="title")
plot2 <- xyplot(z~y, Data, xlab="name", ylab="name", main="title")
plot3 <- xyplot(z~x, Data, xlab="name", ylab="name", main="title")

Hiding globally can be also shown on print() on the above or else all this helps.

like image 974
Maximilian Avatar asked Aug 28 '13 21:08

Maximilian


People also ask

How do I hide the X axis in R?

For example to hide x axis labels, use this R code: p + theme(axis. title. x = element_blank()) . Change the font style of axis labels (size, color and face).

How do you suppress the X axis in a plot?

To hide or remove X-axis labels, use set(xlabel=None). To display the figure, use show() method.

How do I remove X and Y axis labels in R?

When we create a plot in R, the Y-axis labels are automatically generated and if we want to remove those labels, the plot function can help us. For this purpose, we need to set ylab argument of plot function to blank as ylab="" and yaxt="n" to remove the axis title.

What does Lattice mean in R?

Lattice is a powerful and elegant high-level data visualization system for R, inspired by Trellis graphics. It is designed with an emphasis on multivariate data, and in particular allows easy conditioning to produce "small multiple" plots.


2 Answers

Try this

xyplot(1:10~1:10, scales=list(x=list(at=NULL)))

you should read the docs in ?xyplot

like image 98
baptiste Avatar answered Oct 06 '22 04:10

baptiste


You could also try

xyplot(1:10~1:10, scales=list(x=list(draw=FALSE)))

like image 40
Omar Wagih Avatar answered Oct 06 '22 06:10

Omar Wagih