我使用ggplot2構建了一個包含四個繪圖的圖形,每個繪圖都由一個特定的建模域組成。我想用黑體上的字母進行以下繪圖。使用符號太麻煩了,因爲我有8個類別,符號看起來太相似。用ggplot2繪製粗體字母?
下面是一個可再現的例子。
數據:
Covariate.Weights.Data= structure(list(Species = structure(c(1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L,
6L, 6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L,
6L, 6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L,
6L, 6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L), .Label = c("American black duck",
"American wigeon", "Blue-winged teal", "Gadwall", "Green-winged teal",
"Mallard", "Northern pintail", "Northern shoveler"), class = "factor"),
Flyway = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Atlantic",
"Mississippi"), class = "factor"), Season = structure(c(1L,
1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L,
1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L,
2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L,
1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L,
1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L), .Label = c("Fall", "Spring"), class = "factor"),
Covariates = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Forage",
"Habitat", "Survey"), class = "factor"), Weights = c(0.31,
1, 0, 0.96, 0, 0, 1, 0, 1, 1, 0, 0.06, 1, 1, 1, 0.06, 0,
1, 0.01, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0.82, 1, 1, 0.31,
0.43, 0, 0.82, 1, 1, 1, 0.92, 1, 0, 1, 0.97, 1, 1, 0, 0.94,
1, 1, 0.05, 0, 1, 1, 1, 1, 1, 1, 1, 0.07, 0.99, 1, 1, 1,
0.69, 0, 1, 0.04, 0, 0, 0, 0.08, 0, 0, 0, 0.02, 0, 0, 0,
0, 0, 0, 0.94, 0, 0, 0, 0, 0, 0, 0, 0, 0.93, 0.01, 0, 0,
0)), .Names = c("Species", "Flyway", "Season", "Covariates",
"Weights"), class = "data.frame", row.names = c(NA, -96L))
簡介:
require(ggplot2)
Covariates.Weights.Plot =
ggplot(Covariate.Weights.Data, aes(x=Covariates,y=Weights,shape=Species)) +
facet_grid(Flyway~Season) + ylab("Relative Importance") +
geom_point(size=5, position=position_jitter(h=0.1,w=0.3)) +
scale_shape_manual(values=LETTERS[c(1,23,2,7,20,13,16,19)]) +
theme(text=element_text(size=20, face="bold"),
axis.text.y=element_text(size=20),
axis.text.x=element_text(size=20),
axis.title.y=element_text(size=30, face="bold", vjust=1),
axis.title.x=element_text(size=30, face="bold", vjust=0),
strip.text=element_text(size=30, colour="black", face="bold",
vjust=1))
Covariates.Weights.Plot
以防萬一你不知道:如果你使用'geom_text()',你可以直接使用'fontface = 「黑體」'的說法。 – maj