ggplot2 的標題、小標題、題注、附注


p <- ggplot(mtcars, aes(mpg, wt, colour = cyl)) + geom_point()
p + labs(colour = "Cylinders")
p + labs(x = "New x label")

# The plot title appears at the top-left, with the subtitle
# display in smaller text underneath it
p + labs(title = "New plot title")
p + labs(title = "New plot title", subtitle = "A subtitle")

# The caption appears in the bottom-right, and is often used for
# sources, notes or copyright
p + labs(caption = "(based on data from ...)")

# The plot tag appears at the top-left, and is typically used
# for labelling a subplot with a letter.
p + labs(title = "title", tag = "A")

# If you want to remove a label, set it to NULL.
p + labs(title = "title") + labs(title = NULL)

require(tidyverse)

data <- diamonds %>%
sample_n(1000)

ggplot(data = data) +
geom_point(aes(x = carat, y = price, color =price))+
labs(title = "AThis is title",
subtitle = "BThis is subtitle",
caption = "CThis is caption",
tag = "DThis is a tag",
x = "Enew x label",
y = "FNew y label")

 

p+labs(title = "New plot title", subtitle = "A subtitle",caption = "(based on data from ...)", tag = "A")

 

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM