• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Python Viz
  • Seaborn
  • Altair
  • R Viz
  • ggplot2
  • About
    • Privacy Policy
  • Show Search
Hide Search

How to Make Axis Text Bold in ggplot2

datavizpyr · August 26, 2021 ·

In this tutorial, we will learn how to make the axis text bold in a plot made with ggplot2 in R. Axis text in a plot refers to the text annotating the tick marks on x and y-axis. By default the axis text around tick marks are not in bold font and here we will make the axis text bold font using ggplot2’s theme element element_text().

How To Make Axis Text Bold in ggplot2
How To Make Axis Text Bold in ggplot2 with element_text()

Loading Data

First, let us load tidyverse and palmer penguin dataset to make plots using ggplot2.

library(tidyverse)
library(palmerpenguins)
theme_set(theme_bw(16))

A plot with default axis text in ggplot2

Let us make a scatter plot using Palmer penguin data set to see how axis text looks like by default with ggplot2.

penguins %>% 
  drop_na() %>%
  ggplot(aes(x = flipper_length_mm,
             y = body_mass_g,
             color = species)) + 
   geom_point() 
ggsave("simple_ggplot.png")

Simple plot with ggplot2 in R
Simple plot with ggplot2 in R

How to Make Axis Text Bold Font: element_text in ggplot2

We can make axis text, text annotating x and y axis tick marks, bold font using theme() function. Here we specify axis.text argument to make both x and y-axis text bold using element_text() function. We can make the axis text font bold by using face=”bold” argument to element_text() function.

penguins %>% 
  drop_na() %>%
  ggplot(aes(x = flipper_length_mm,
             y = body_mass_g,
             color = species)) + 
   geom_point() +
  theme(axis.text = element_text(face="bold"))
ggsave("bold_axis_text_with_element_text_ggplot2.png")

Note now the both x and y-axis text are in bold font and more clearly visible than the default axis text.

How to Make Axis Text Bold with ggplot
Make Axis Text Bold with ggplot2

One can also make the axis text on one of the axes selectively. For example, by using axis.text.x = element_text(face=”bold”) we can make x-axis text bold font. Similarly, by using axis.text.y = element_text(face=”bold”), we can make y-axis text bold font.

Related posts:

Customizing Mean mark to boxplot with ggplot2How To Show Mean Value in Boxplots with ggplot2? Scatterplot with marginal multi-histogram with ggExtraHow To Make Scatterplot with Marginal Histograms in R? ggforce geom_circle(): Annotate with a circleHow To Annotate a Plot with Circle in R Make Axis Title Bold Font with element_text()How to Make Axis Title Bold Font with ggplot2

Filed Under: ggplot2, R Tagged With: axis text bold font in R, axis text bold ggplot2

Primary Sidebar

Tags

Altair barplot Boxplot boxplot python boxplot with jiitered text labels Bubble Plot Color Palette Countplot Density Plot Facet Plot gganimate ggplot2 ggplot2 Boxplot ggplot2 error ggplot boxplot ggridges ggtext element_markdown() Grouped Barplot R heatmap heatmaps Histogram Histograms Horizontal boxplot Python lollipop plot Maps Matplotlib Pandas patchwork pheatmap Pyhon Python R RColorBrewer reorder boxplot ggplot Ridgeline plot Scatter Plot Scatter Plot Altair Seaborn Seaborn Boxplot Stock Price Over Time Stripplot UpSetR Violinplot Violin Plot World Map ggplot2

Buy Me a Coffee

Copyright © 2025 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version