1
我有兩個功能y1
和y2
。強制ggplot顯示2曲線功能
如果我單獨繪製它們沒有問題(參見兩個第一圖)。
但是,如果我將它們合併,形狀看起來是線性的(參見圖3)。
我該如何解決這個問題?
x <- seq(0, 50, 1) ;x
y1 <- exp(8.9191)+exp^(0.03307*x)
y2 <- exp(9.9191)+exp^(0.06307*x)
df <- data.frame(x,y1,y2)
require(ggplot2)
ggplot(df, aes(x)) +
geom_line(aes(y=y2), colour="red") #Looks nice (curvy)
ggplot(df, aes(x)) +
geom_line(aes(y=y1), colour="blue") #Looks nice (curvy)
ggplot(df, aes(x)) +
geom_line(aes(y=y1), colour="blue") +
geom_line(aes(y=y2), colour="red") #Looks not nice linear
...因爲他們在巨大的不同尺度?這幾乎是不可能調和的:因爲有很大的加性常數,所以即使增加一個對數垂直尺度也沒有多大幫助。 –
你想比較什麼?也許有更好的方式來表示數據。 –
紅色曲線代表女性和藍色男性。所以我試圖比較男人和女人的區別。在我的例子中x軸沒有任何表示。但是,您可以想象,x軸是工作經驗,y軸可以代表工資。 – S12000