「lege artis」以居中證明陰謀標題的方式 - ggplot - plot.title = element_text(hjust = 0.5) - 居中標題在陰謀區域排除軸標籤。如何居中ggplot陰謀標題
當軸標籤非常長時,如Mary Poppins Soundtrack中的這首歌曲曲線與其字符長度相比,這會變得很難看。
library(tidyverse)
mary_poppins <- data_frame(song = c("Overture", "Sister Suffragette", "The Life I Lead", "The Perfect Nanny", "A Spoonful of Sugar", "Pavement Artist", "Jolly Holiday", "Supercalifragilisticexpialidocious", "Stay Awake", "I Love to Laugh", "A British Bank", "Feed the Birds ", "Fidelity Fiduciary Bank", "Chim Chim Cher-ee", "Step in Time", "A Man Has Dreams", "Let's Go Fly a Kite"
))
mary_poppins <- mary_poppins %>%
mutate(len = nchar(song))
ggplot(data = mary_poppins, aes(x = reorder(song, len), y = len)) +
geom_col(fill = "firebrick") +
coord_flip() +
theme_light() +
theme(axis.title.y = element_blank(),
axis.text = element_text(size = rel(1.5)),
plot.title = element_text(size = rel(2.5), face = "bold", hjust = 0.5,
margin = margin(t = 10, b = 20, unit = "pt"))) +
ggtitle("Mary Poppins") +
ylab("Lenght of title (characters)")
有沒有辦法在總用地面積,即居中標題。包括軸標籤佔用的區域?
謝謝 - 這確實是一個比填充空間更簡潔的解決方案! –