2
我使用ggplot2來製作一個簡單的圖形,但它有太多的空白。scale_x_discrete中x軸刻度線之間的距離太遠
我想的兩個點是更靠近在一起,在x軸,使整體圖像較小。我使用scale_x_discrete用下面的代碼:
ggplot(box, aes(x=Garden, y=Fitness)) +
geom_errorbar(aes(ymin=(Fitness-Error), ymax=(Fitness+Error)),
colour="black", width=.05) +
geom_line() +
geom_point(size=6)+
theme(panel.background = element_rect(fill =
'white'),axis.text=element_text(size=22),
axis.title=element_text(size=28,face="bold"),legend.key = element_rect(fill = "white"), plot.title = element_text(size=30,face="bold", hjust=0.5),axis.title.y = element_text(margin = margin(t = 0, r = 20, b = 0, l = 0)), axis.ticks.length = unit(0, "lines"),legend.text=element_text(size=24),legend.title=element_text(size=26), legend.key.size = unit(1.5, 'lines'))+
ggtitle("Fitness Comparison") + labs(y="Ranked Fitness", x = "Common Garden") +
scale_x_discrete(labels=c("Warm" = "Warm Limit", "Cool" = "Cool Limit"), expand=c(0.2, 0))
驚人!非常感謝。像魅力一樣工作。 –