• 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 Title Bold in ggplot2?

datavizpyr · February 3, 2020 ·

One of the common failures of making a data visualization is wither not having a title for plot or having a title that is not easy to read. Making the title in bold can help making the visualiation better. In this post, we will learn how to make the title of plot made with ggplot bold font.

Let us loadtidyverse, the suite of R packages from RStudio.

library(tidyverse)
theme_set(them_bw())

We will use cars data that inbuilt with R to make a simple scatter plot with a default title size.

head(cars)
##   speed dist
## 1     4    2
## 2     4   10
## 3     7    4
## 4     7   22
## 5     8   16
## 6     9   10

Let us make a scatter plot with speed on x-axis and dist on y-axis using geom_point(). We will also add a title using ggplot function labs().

cars %>% 
  ggplot(aes(x=speed,y=dist)) + 
  geom_point()+
  labs(title="Speed vs Distance")

By default the title made by ggplot is not in bond font.

ggplot with default title
ggplot with default title

We can make the title of a plot bold in ggplot2 using theme() function. theme function can handle many aspects of the ggplot2 theme including title. To change the title font to bold, we can use plot.title argument and specify element_text(face=”bold”) as shown below.

cars %>% 
  ggplot(aes(x=speed,y=dist)) + 
  geom_point()+
  labs(title="Speed vs Distance")+
  theme(plot.title = element_text(face="bold"))

And now our plot’s title is bold as we wanted.

Make Title Bold in ggplot2
Make Title Bold in ggplot2

We can also increase the size of the text using size argument inside element_text() in addition to the face=bold argument.

cars %>% 
  ggplot(aes(x=speed,y=dist)) + 
  geom_point()+
  labs(title="Speed vs Distance")+
  theme(plot.title = element_text(face="bold", size=18))

Now we have the title with larger fontsize and in bold.

ggplot: increase title size
ggplot: increase title size

Related posts:

How to Make Heatmap with ggplot2?How To Make Simple Heatmaps with ggplot2 in R? Stacked Barplots Side By Side with ggplot2 in RHow to Make Horizontal Stacked Barplots with ggplot2 in R? Scatter Plot R: Fill color by variableHow To Color Scatter Plot by Variable in R with ggplot2? How to Make Barplots with Error bars in R?How To Make Barplots with Error bars in ggplot2?

Filed Under: make title bold ggplot2, R Tagged With: ggplot2, R

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