0
我試着做一個陰謀如下。如何在保存級別設置2個不同的y軸?
但是我的2個y軸不在不同的水平。此外,我無法在「紅色」中設置左側的Y軸「WD」
有沒有人能幫我弄清楚這兩個問題?
非常感謝!
DLPM10$hours <- as.integer(gsub('.* |:.*', '', DLPM10$date))
dt <- group_by(DLPM10, hours) %>%
summarise(WD = mean(WD_DOUGLAS, na.rm = TRUE), WS = mean(WS_DOUGLAS, na.rm = TRUE))
par(mar=c(5,4,4,5)+.1)
barplot(height = dt$WD, axes=FALSE, border =NA,space = 0.4,ylim=c(0,370),
col="red",xlab = 'Hour', ylab = 'WD', main = "Dougals Red Cross")
axis(2, ylim=c(0,370),col="red",col.axis="red",col.lab="red",las=1)
par(new = TRUE)
plot(dt$hours, dt$WS,axes = FALSE, bty = 'n',pch= 19,xlim = c(-.35, 23.35),
ylim=c(0,5), col="blue", xlab = '', ylab = '')
axis(4, 0:5, col="blue", col.axis="blue",las=1)
mtext('WS', dt$WS,col="blue", side = 4, line = 2)
axis(1, 0:23, pos = -0.2)
legend("topleft",legend=c("WS","WD"),bty = "n",
bg = par("bg"),
text.col=c("blue","red"),pch=c(19,15),
col=c("blue","red"),horiz= T,text.width= 0.01)
謝謝你的幫助。對不起,它不適合我。我發現如果我改變barplot(height = dt $ WD,axes = FALSE,border = NA,space = 0.4,ylim = c(-10,370), col =「red」,xlab ='Hour',ylab ='WD ',main =「道格拉斯紅十字會」)兩軸現在都很近,但是。如果在同一級別,我不是100%。 –