scale_x_discrete中x轴刻度线之间的距离太远

时间:2017-09-01 19:06:29

标签: ggplot2 scale

我使用ggplot2制作一个简单的图形,但它有太多的空白区域。

Comparison graph

我希望这两个点在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))

1 个答案:

答案 0 :(得分:1)

减少两个误差线之间的空白区域的方法是使用带void Start() { StartCoroutine(deleteRequest("http:///www.yoururl.com")); } IEnumerator DeleteRequest(string url) { UnityWebRequest uwr = UnityWebRequest.Delete(url); yield return uwr.SendWebRequest(); if (uwr.isNetworkError) { Debug.Log("Error While Sending: " + uwr.error); } else { Debug.Log("Deleted"); } } 的连续x变量。

scale_x_continuous

enter image description here