![](/img/trans.png)
[英]R: ggplot: two plots in one dataframe: color one plot only when it is less than the other plot
[英]R ggplot reversing one axis of a plot when there is more than one plot in the graph without affecting other plots
我使用ggplot2繪制了降雨數據集。 我必須將Rainfall和Stream fall數據繪制在我使用它完成的相同圖形中
p <- ggplot(data=raw_data, aes(x=Hr, y=RF)) +
geom_bar(stat="identity")
p <- p + geom_line(aes(x= Hr, y=SF))
我的問題是如何使條形圖顛倒。 我已經嘗試過使用ylim(60,0)
和scale_y_reverse
,這使得兩個圖形都顛倒了。 任何幫助。
嘗試這個
require(ggplot2)
df1 <- data.frame(x=c(1,2), y=c(3,4))
dfdummy <- data.frame(xx=c(1,2), yy=c(5,5))
# here the arbitrary hang height is 5, see yy.
ggplot() +
geom_bar(data=dfdummy, aes(x=xx, y=yy), stat="identity") + # dummy bars
geom_bar(data=df1, aes(x=x, y=y), stat="identity", fill="white") + # overwriting dummy
theme_classic() # theme w/o grid lines and background matching fill means invisible data
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.