Table of Contents
Introduction: The Role of Custom Visualization in R
When creating statistical graphics using the powerful ggplot2 package in R, clarity is usually the primary goal. However, there are scenarios in advanced data visualization—such as creating small multiples, inset plots, or charts intended for purely aesthetic display—where standard axis labels and tick marks become redundant or clutter the visual field. Learning how to precisely control these elements is a key skill for any intermediate R user.
The ability to manipulate every aesthetic element in your plot is one of the defining features of ggplot2, which follows the grammar of graphics philosophy. To achieve customization, we primarily rely on the theme() function. This function allows developers to override the default settings for non-data elements like titles, backgrounds, legends, and, critically, axis annotations.
This comprehensive guide will walk you through the necessary syntax to systematically remove axis labels and tick marks from your visualizations. We will explore specific examples demonstrating how to hide the x-axis, the y-axis, or both simultaneously, ensuring you maintain clean and professional graphic output suitable for publication or presentation.
The Core Syntax for Axis Manipulation
Removing visual components within ggplot2 is managed by mapping an element (like axis text or ticks) to the special function element_blank() within the overarching theme() layer. This instruction tells the plotting engine to draw nothing for that specific component, effectively hiding it.
The following fundamental syntax demonstrates how to remove all primary axis components—the labels and the tick marks—for both the X and Y axes in a general plot structure. Understanding this structure is essential before moving on to specific examples.
ggplot(df, aes(x=x, y=y))+ geom_point() + theme(axis.text.x=element_blank(), #remove x axis labels axis.ticks.x=element_blank(), #remove x axis ticks axis.text.y=element_blank(), #remove y axis labels axis.ticks.y=element_blank() #remove y axis ticks )
In the syntax above, axis.text.x refers to the numerical or categorical labels displayed along the horizontal axis, while axis.ticks.x refers to the small lines indicating those values. By setting them to element_blank(), we achieve complete removal. The same logic applies to axis.text.y and axis.ticks.y for the vertical axis.
We will now proceed with practical demonstrations, applying this specialized syntax to a standard scatter plot visualization using synthetic data, illustrating how to customize each axis independently.
Example 1: Isolating and Removing X-Axis Elements
Often, visualizations are stacked or presented side-by-side where the X-axis labels are only necessary for the bottom plot. In such cases, removing the X-axis labels from the upper plots helps create a visually cohesive and less cluttered presentation. This example focuses exclusively on removing the horizontal axis labels and their corresponding tick marks.
We begin by loading the ggplot2 library and generating a simple data frame containing ten paired (x, y) observations. This foundational step is crucial for reproducibility and for defining the data source that our plot will visualize.
library(ggplot2)
#create data frame
df <- data.frame(x=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
y=c(11, 13, 15, 14, 19, 22, 28, 25, 30, 29))
#create scatterplot
ggplot(df, aes(x=x, y=y))+
geom_point() +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank()
)
The key modification occurs within the theme() layer, where we target axis.text.x and axis.ticks.x. By applying element_blank() solely to these properties, we ensure that the vertical axis remains fully labeled, providing context for the Y values while streamlining the horizontal axis display.
Observe the resulting visualization below. You can clearly see that only the x-axis labels and tick marks have been successfully removed, leaving the plot points centered within the graphical area without the bottom numerical context. This technique is highly effective when the X variable is less important or when the graph relies on other contextual labels.

This approach grants precise control. If you only wanted to remove the tick marks but keep the labels, you would simply omit the axis.text.x=element_blank() line, demonstrating the modularity of the ggplot2 system.
Example 2: Customizing the Y-Axis Appearance
In contrast to the previous example, there are times when the Y-axis—representing the dependent variable or a measured outcome—is the primary candidate for removal. This is particularly relevant when multiple graphs share the same scale or when the absolute values are less important than the spatial relationship of the points themselves.
We reuse the established boilerplate code for loading the library and setting up our small data frame, ensuring consistency across all examples. The initial data preparation is identical, allowing us to focus purely on the graphical customization layer.
library(ggplot2)
#create data frame
df <- data.frame(x=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
y=c(11, 13, 15, 14, 19, 22, 28, 25, 30, 29))
#create scatterplot
ggplot(df, aes(x=x, y=y))+
geom_point() +
theme(axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
To target the vertical axis, we utilize axis.text.y and axis.ticks.y within the theme() function. This modification leaves the X-axis labels intact, preserving the numerical context for the horizontal position of the points while eliminating the numerical context for the vertical position.
The resulting plot confirms that only the y-axis labels and associated tick marks have been removed. This technique is often employed in complex dashboards or matrix plots where a single, shared Y-axis label or title suffices for an entire row of visualizations. It helps reduce visual redundancy significantly.

Example 3: Achieving a Label-Free Visualization
For highly minimalist or decorative visualizations, or when the data context is provided entirely through tooltips or external text, it may be necessary to remove all axis labels and ticks entirely. This results in a stark, clean canvas showing only the geometric elements (in this case, the points) within the defined plotting area.
This final example demonstrates the combination of the techniques covered previously. We use the same initialization process in R, defining our data and initiating the ggplot2 environment. The visualization is created using geom_point(), mapping the variables using aes().
library(ggplot2)
#create data frame
df <- data.frame(x=c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
y=c(11, 13, 15, 14, 19, 22, 28, 25, 30, 29))
#create scatterplot
ggplot(df, aes(x=x, y=y))+
geom_point() +
theme(axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
By including all four relevant parameters—axis.text.x, axis.ticks.x, axis.text.y, and axis.ticks.y—and assigning element_blank() to each, we achieve maximum minimalism regarding the axes. This code snippet represents the most comprehensive way to strip away axis annotations using the theme() function.
The final output, as displayed below, shows the scatter plot points floating in the plotting area, entirely devoid of numerical or textual axis context. This is highly effective when the visualization’s purpose is to show trends or relationships rather than exact coordinates.

It is important to note that removing labels does not remove the axis lines themselves (the baseline borders). To remove those, you would need to set axis.line.x = element_blank() and axis.line.y = element_blank(), offering yet another layer of customization within the powerful theme() system.
Summary and Best Practices
Mastering the theme() function is fundamental to advanced visualization design in R. The ability to selectively remove axis labels and ticks using element_blank() provides the flexibility necessary for producing highly customized and context-appropriate graphics. Whether you need a label-free chart for aesthetic appeal or are simplifying a multi-panel display, these techniques ensure your output is professional and clean.
When deciding whether to remove axis elements, consider the audience and the context of the visualization. While minimalist plots look appealing, they must still convey the necessary information. If the absolute scale is critical, maintain the labels; if the relative positioning or overall trend is sufficient, removing them often enhances visual focus on the data itself.
We highly recommend exploring the full documentation for the ggplot2 package, as the theme() function supports hundreds of options for customizing every aspect of plot appearance, from fonts and colors to gridlines and panel backgrounds.
Additional Resources for ggplot2 Customization
To further enhance your skills in data visualization using ggplot2, consider exploring tutorials focused on the following common customization challenges:
Changing plot titles and subtitles.
Modifying the overall plot background and panel grid lines.
Customizing legend positions and appearance.
Using different geometric layers (e.g.,
geom_line(),geom_bar()) in conjunction with these theme modifications.
The provided examples serve as a robust foundation for manipulating specific plot components, ensuring you have complete control over the final visual output of your data analysis in R.
Cite this article
Mohammed looti (2025). Remove Axis Labels in ggplot2 (With Examples). PSYCHOLOGICAL STATISTICS. Retrieved from https://statistics.arabpsychology.com/remove-axis-labels-in-ggplot2-with-examples/
Mohammed looti. "Remove Axis Labels in ggplot2 (With Examples)." PSYCHOLOGICAL STATISTICS, 3 Nov. 2025, https://statistics.arabpsychology.com/remove-axis-labels-in-ggplot2-with-examples/.
Mohammed looti. "Remove Axis Labels in ggplot2 (With Examples)." PSYCHOLOGICAL STATISTICS, 2025. https://statistics.arabpsychology.com/remove-axis-labels-in-ggplot2-with-examples/.
Mohammed looti (2025) 'Remove Axis Labels in ggplot2 (With Examples)', PSYCHOLOGICAL STATISTICS. Available at: https://statistics.arabpsychology.com/remove-axis-labels-in-ggplot2-with-examples/.
[1] Mohammed looti, "Remove Axis Labels in ggplot2 (With Examples)," PSYCHOLOGICAL STATISTICS, vol. X, no. Y, ص Z-Z, November, 2025.
Mohammed looti. Remove Axis Labels in ggplot2 (With Examples). PSYCHOLOGICAL STATISTICS. 2025;vol(issue):pages.