• 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 Title Bold Font with ggplot2

datavizpyr · September 6, 2021 ·

In this tutorial, we will learn how to change the axis title bold font with ggplot2 in R. Let us load the packages needed including tidyverse and palmerpenguins for penguins data.

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

A plot with default font for axis title text

Let us make a simple scatter plot using ggplot2 to see how the default font for both x and y-axis title looks like.

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

How to Make Axis Title Bold Font in ggplot2
How to Make Axis Title Bold Font in ggplot2

Make Axis Title Text Bold Font with element_text()

We can change the appearance text elements of a plot made with ggplot2 using theme element element_text() function. To make both x and y-axis’s title text in bold font, we will use axis.title argument to theme() function with element_text(face=”bold”).

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

Note now both x and y axis’s title text are in bold font.

Make Axis Title Bold Font with element_text()
Make Axis Title Bold Font with element_text()

Make X and Y Axis Title Text Bold Font Separately with element_text()

In the above example, we changed both x and y-axis’s title text into bold. We can also specify either x or y-axis alone to customize the look of text using element_text(). For example, to make the title text of x-axis aloine in bold font, we will use “axis.title.x”

penguins %>% 
  drop_na() %>%
  ggplot(aes(x = flipper_length_mm,
             y = bill_length_mm,
             color = species)) + 
   geom_point() +
  theme(axis.title.x = element_text(face="bold"))

Similarly, to make the y-axis title text’s font into bold we can use “axis.title.y” as shown below.

penguins %>% 
  drop_na() %>%
  ggplot(aes(x = flipper_length_mm,
             y = bill_length_mm,
             color = species)) + 
   geom_point() +
  theme(axis.title.y = element_text(face="bold"))

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 Default ThumbnailHow to Make Axis Text Bold in ggplot2

Filed Under: ggplot2, R Tagged With: axis title bold element_text, axis title 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