Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Axes > Removing Tick Marks and Labels

Removing Tick Marks and Labels

Problem

You want to remove tick marks and labels.

Solution

To remove just the tick labels, as in Figure 8-14 (left), use theme(axis.text.y = element_blank()) (or do the same for axis.text.x). This will work for both continuous and categorical axes:

p <- ggplot(PlantGrowth, aes(x=group, y=weight)) + geom_boxplot()

p + theme(axis.text.y = element_blank())
Left: no tick labels on y-axis; middle: no tick marks and
            no tick labels on y-axis; right: with breaks=NULL
Figure 8-14. Left: no tick labels on y-axis; middle: no tick marks and no tick labels on y-axis; right: with breaks=NULL

To remove the tick marks, use theme(axis.ticks=element_blank()). This will remove the tick marks on both axes. (It’s not possible to hide the tick marks on just one axis.) In this example, we’ll hide all tick marks as well as the y tick labels (Figure 8-14, center):


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint