Matplotlib removes both labels and ticks by using xaxis. set_visible() set_visible() method removes axis ticks, axis tick labels, and axis labels also. It makes the axis invisible completely.
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.
The axes labels and ticks can be removed in ggplot using the theme() method. This method is basically used to modify the non-data components of the made plot. It gives the plot a good graphical customized look. The theme() method is used to work with the labels, ticks, and text of the plot made.
Click anywhere in the chart for which you want to display or hide axes. This displays the Chart Tools, adding the Design, Layout, and Format tabs. On the Layout tab, in the Axes group, click Axes. Click the type of axis that you want to display or hide, and then click the options that you want.
Remove numbering on x-axis or y-axis:
plot(1:10, xaxt='n')
plot(1:10, yaxt='n')
If you want to remove the labels as well:
plot(1:10, xaxt='n', ann=FALSE)
plot(1:10, yaxt='n', ann=FALSE)
Using base graphics, the standard way to do this is to use axes=FALSE, then create your own axes using Axis (or axis). For example,
x <- 1:20
y <- runif(20)
plot(x, y, axes=FALSE, frame.plot=TRUE)
Axis(side=1, labels=FALSE)
Axis(side=2, labels=FALSE)
The lattice equivalent is
library(lattice)
xyplot(y ~ x, scales=list(alternating=0))
@Richie Cotton has a pretty good answer above. I can only add that this page provides some examples. Try the following:
x <- 1:20
y <- runif(20)
plot(x,y,xaxt = "n")
axis(side = 1, at = x, labels = FALSE, tck = -0.01)
you can also put labels inside plot:
plot(spline(sub$day, sub$counts), type ='l', labels = FALSE)
you'll get a warning. i think this is because labels is actually a parameter that's being passed down to a subroutine that plot runs (axes?). the warning will pop up because it wasn't directly a parameter of the plot function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With