0
我有一些氣象數據,我正在繪製一個顯示月平均值的時間序列。我在同一塊劇情畫布上將降雨量作爲一個條線圖和溫度作爲線條圖。我需要生成一個帶有不同符號的圖例,例如降雨的彩色框,以及兩個用於溫度的彩色線。酒吧和線圖的圖例組合
這裏的數據
> month max_temp min_temp rain humid
> Jan 24.65032258 12.54193548 1.425806452 75.44064516
> Feb 25.65248227 13.39219858 1.876595745 79.06666667
> Mar 24.26129032 12.41354839 2.318709677 83.55806452
> Apr 21.038 10.62933333 5.013333333 90.026
> May 17.29548387 7.16516129 4.080645161 91.83225806
> Jun 14.98733333 5.529333333 4.4 91.2
> Jul 13.98516129 4.06516129 3.987096774 90.60322581
> Aug 15.18258065 5.316129032 3.350322581 89.26129032
> Sep 16.434 7.668 4.229333333 84.03666667
> Oct 18.13225806 8.481290323 2.277419355 81.26129032
> Nov 20.07666667 9.558666667 2.562 75.99266667
> Dec 22.51032258 12.13225806 2.296774194 76.28193548
這是我的代碼來生成情節
weather<-weather
month_number<-seq(1,12,1)
months<-months[1:12]
new<-data.frame(rain=c(weather$rain),order=c(months))
graph<-barplot(height=new$rain, names.arg=new$order,col="light blue",
cex.axis=0.2,border=NA,xaxt='n',yaxt="n",xlab="",ylab="",ylim=c(0,10))
axis(side=1, pos=0,tck=-0.05,at=graph, labels=months[1:12],cex.axis=0.7,las=2,font.axis=2)
axis(4,las="1",cex.axis=0.7,font.axis=2)
mtext("Accumulated rainfall (mm)",side=4,line=2,cex=0.7)
par(new=TRUE)
weather$x<-month_number
plot(weather$x,weather$max_temp,type="l",las=1,col="red",lwd=1.5,xaxt="n",
ylim=c(0,30),xlab=NA,ylab = expression(paste("Temperature ",degree,"C")),
,cex.lab=0.8,cex.axis=0.7,font.axis=2)
lines(weather$x,weather$min_temp,col="blue",lwd=1.5)
legend("bottom",inset=c(0,1.05),legend=c("Rainfall", "Max temp", "Min temp"),xpd=TRUE,
,horiz=TRUE,pch=c(15),col=c("light blue","red","blue"),
lty=c(0,1,1),lwd=2,title=NA,cex=0.6,bty='n')
和劇情本身。在圖例中,我想增加降雨情節字符的大小,並完全忽略這兩個溫度的行中顯示的情節字符。字體大小需要保持不變。我試過pch=26
,我有seen plots a null character但我收到一條錯誤消息。也looked here但它並沒有解決我的問題。