1
My圖表看起來是這樣的:當x值是類型因子時,如何設置多線圖(ggplot)繪圖區域的限制?
我使用的代碼是這樣的
graph_substrat <- ggplot(substrat_long, aes(x=substrat,y=value,
+ group=variable, linetype=variable)) + geom_line() + ylab("Suitability Index")
+ xlab("Substrat") + background_grid(major = "xy", minor = "none")
graph_substrat <- graph_substrat + theme(legend.position="none")
我只是想繪製卵石和沙子之間線,和自由刪除空間在圖的開頭和結尾,以便這些行從Y軸開始(或至少非常接近它,並以X軸上的最後一個刻度結束)。
我試過limits
,expand
和coord_cartesian
,但它沒有奏效。
請注意,X的類型爲factor
而不是numeric
。
謝謝!我試圖用'expand = c(0,0)'來解決它,但是我做了錯誤的美學。 'scale_x_discrete(expand = c(0,0))'訣竅! –