• 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 Move Facet strip label to the bottom

datavizpyr · August 21, 2024 ·

In this tutorial, we will learn how to move the strip label title text in ggplot2’s facet* functions to the bottom. By default, facet_wrap() creates a box for each strip with a label at the top of the small multiple plot. In this post, we will show how to move the strip label to the bottom using ‘strip.position = “bottom”‘ argument to facet_wrap() function first and then placing the label at the correct bottom location using `strip.placement = “outside”`argument to theme() function.

Let us load the packages needed.

library(palmerpenguins)
library(tidyverse)
theme_set(theme_bw(16))
penguins |>
  head()

# A tibble: 6 × 8
  species island    bill_length_mm bill_depth_mm flipper_length_mm body_mass_g
  <fct>   <fct>              <dbl>         <dbl>             <int>       <int>
1 Adelie  Torgersen           39.1          18.7               181        3750
2 Adelie  Torgersen           39.5          17.4               186        3800
3 Adelie  Torgersen           40.3          18                 195        3250
4 Adelie  Torgersen           NA            NA                  NA          NA
5 Adelie  Torgersen           36.7          19.3               193        3450
6 Adelie  Torgersen           39.3          20.6               190        3650
# ℹ 2 more variables: sex <fct>, year <int>

Here is how the default plot made with facet_wrap() in ggplot2 looks like. Each small plot has the strip label at the top in a grey box.

penguins |>
  drop_na() |>
  ggplot(aes(x=sex, y=flipper_length_mm, color=species))+
  geom_boxplot()+
  facet_wrap(~species)+
  labs(title="Palmer Penguins Dataset")+
  theme(legend.position="none")
ggsave("default_facet_wrap_ggplot.png")
Default facet_wrap() with facet strip label at the top in ggplot2
Default facet_wrap() with facet strip label at the top in ggplot2

Move facet strip label from top to bottom using “strip.position”

Let us move the strip label from top to bottom by adding the argument “strip.position =
bottom” to the facet_wrap() function.

penguins |>
  drop_na() |>
  ggplot(aes(x=sex, y=flipper_length_mm, color=species))+
  geom_boxplot()+
  facet_wrap(~species, strip.position = "bottom")+
  labs(title="Palmer Penguins Dataset")+
  theme(legend.position="none")
ggsave("Move_facet_strip_label_to_bottom_ggplot.png")
How to move the facet strip label to the bottom in ggplot2
How to move the facet strip label to the bottom in ggplot2

Move facet strip label to outside x-axis tick at bottom using “strip.placement”

Although we have move the strip label or the tile text to the facet to the bottom, it is not in the right place. We can see that the strip label is above the x-axis tick labels. Let us move the strip label to outside by adding the argument strip.placement = “outside” to the theme() function.

penguins |>
  drop_na() |>
  ggplot(aes(x=sex, y=flipper_length_mm, color=species))+
  geom_boxplot()+
  facet_wrap(~species, strip.position = "bottom")+
  labs(title="Palmer Penguins Dataset")+
  theme(legend.position="none",
        strip.placement = "outside")
ggsave("Move_facet_strip_label_outside_x_axis_tick_at_bottom_ggplot.png")
How to move the facet strip label at the bottom to outside x-axis tick label in ggplot2
How to move the facet strip label at the bottom to outside x-axis tick label in ggplot2

Customize facet strip label at bottom by removing strip box

We can further customize by removing the grey box around the strip label.

penguins |>
  drop_na() |>
  ggplot(aes(x=sex, y=flipper_length_mm, color=species))+
  geom_boxplot()+
  facet_wrap(~species, strip.position = "bottom")+
  labs(title="Palmer Penguins Dataset", x=NULL)+
  theme(legend.position="none",
        strip.placement = "outside",
         strip.background = element_blank())
ggsave("remove_facet_strip_box_ggplot.png")
Customize the facet strip label at bottom by removing facet label box
Customize the facet strip label at bottom by removing facet label box

Related posts:

Remove title box in facet_wrap() in ggplot2How To Remove facet_wrap Title Box in ggplot2? Default ThumbnailHow to add P-value to each facet in ggplot2 Customizing Mean mark to boxplot with ggplot2How To Show Mean Value in Boxplots with ggplot2? facet_wrap() example with white boxHow To Change facet_wrap() Box Color in ggplot2?

Filed Under: facet_wrap ggplot2, facet_wrap remove box, ggplot2, R Tagged With: move facet strip label

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