par(mfrow=c(3,3))
# mortality age 50
plot(DataAge50$Year,DataAge50$DA_Female/DataAge50$EA_Female,xlab="Year",ylab="Mortality rates",main="Age 50",type="l",col="green",cex=1)
lines(DataAge50$Year,DataAge50$DBC_Female/DataAge50$EBC_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="blue",cex=1)
lines(DataAge50$Year,DataAge50$DM_Female/DataAge50$EM_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="red",cex=1)
lines(DataAge50$Year,DataAge50$DNB_Female/DataAge50$ENB_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="black",cex=1)
lines(DataAge50$Year,DataAge50$DNL_Female/DataAge50$ENL_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="yellow",cex=1)
lines(DataAge50$Year,DataAge50$DNTN_Female/DataAge50$ENTN_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="beige",cex=1)
lines(DataAge50$Year,DataAge50$DNS_Female/DataAge50$ENS_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="orange",cex=1)
lines(DataAge50$Year,DataAge50$DO_Female/DataAge50$EO_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="blue",cex=1)
lines(DataAge50$Year,DataAge50$DPEI_Female/DataAge50$EPEI_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="grey",cex=1)
lines(DataAge50$Year,DataAge50$DQ_Female/DataAge50$EQ_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="chocolate",cex=1)
lines(DataAge50$Year,DataAge50$DS_Female/DataAge50$ES_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="salmon",cex=1)
lines(DataAge50$Year,DataAge50$DY_Female/DataAge50$EY_Female,xlab="Year",ylab="Mortality rates",main="Age=50",type="l",col="maroon",cex=1)
#Moratlity rates by age=55
plot(DataAge55$Year,DataAge55$DA_Female/DataAge55$EA_Female,xlab="Year",ylab="Mortality rates",main="Age 55",type="l",col="green",cex=1)
lines(DataAge55$Year,DataAge55$DBC_Female/DataAge55$EBC_Female,xlab="Year",ylab="Mortality rates",main="Age 55",type="l",col="blue",cex=1)
lines(DataAge55$Year,DataAge55$DM_Female/DataAge55$EM_Female,xlab="Year",ylab="Mortality rates",main="Age 55",type="l",col="red",cex=1)
lines(DataAge55$Year,DataAge55$DNB_Female/DataAge55$ENB_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="black",cex=1)
lines(DataAge55$Year,DataAge55$DNL_Female/DataAge55$ENL_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="yellow",cex=1)
lines(DataAge55$Year,DataAge55$DNTN_Female/DataAge55$ENTN_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="beige",cex=1)
lines(DataAge55$Year,DataAge55$DNS_Female/DataAge55$ENS_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="orange",cex=1)
lines(DataAge55$Year,DataAge55$DO_Female/DataAge55$EO_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="blue",cex=1)
lines(DataAge55$Year,DataAge55$DPEI_Female/DataAge55$EPEI_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="grey",cex=1)
lines(DataAge55$Year,DataAge55$DQ_Female/DataAge55$EQ_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="chocolate",cex=1)
lines(DataAge55$Year,DataAge55$DS_Female/DataAge55$ES_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="salmon",cex=1)
lines(DataAge55$Year,DataAge55$DY_Female/DataAge55$EY_Female,xlab="Year",ylab="Mortality rates",main="Age=55",type="l",col="maroon",cex=1)
#mortality age 60
plot(DataAge60$Year,DataAge60$DA_Female/DataAge60$EA_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="green",cex=1)
lines(DataAge60$Year,DataAge60$DBC_Female/DataAge60$EBC_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="blue",cex=1)
lines(DataAge60$Year,DataAge60$DM_Female/DataAge60$EM_Female,xlab="Year",ylab="Mortality rates",main="Age 60",type="l",col="red",cex=1)
lines(DataAge60$Year,DataAge60$DNB_Female/DataAge60$ENB_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="black",cex=1)
lines(DataAge60$Year,DataAge60$DNL_Female/DataAge60$ENL_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="yellow",cex=1)
lines(DataAge60$Year,DataAge60$DNTN_Female/DataAge60$ENTN_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="beige",cex=1)
lines(DataAge60$Year,DataAge60$DNS_Female/DataAge60$ENS_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="orange",cex=1)
lines(DataAge60$Year,DataAge60$DO_Female/DataAge60$EO_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="blue",cex=1)
lines(DataAge60$Year,DataAge60$DPEI_Female/DataAge60$EPEI_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="grey",cex=1)
lines(DataAge60$Year,DataAge60$DQ_Female/DataAge60$EQ_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="chocolate",cex=1)
lines(DataAge60$Year,DataAge60$DS_Female/DataAge60$ES_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="salmon",cex=1)
lines(DataAge60$Year,DataAge60$DY_Female/DataAge60$EY_Female,xlab="Year",ylab="Mortality rates",main="Age=60",type="l",col="maroon",cex=1)
#mortality age 65
plot(DataAge65$Year,DataAge65$DA_Female/DataAge65$EA_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="green",cex=1)
lines(DataAge65$Year,DataAge65$DBC_Female/DataAge65$EBC_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="blue",cex=1)
lines(DataAge65$Year,DataAge65$DM_Female/DataAge65$EM_Female,xlab="Year",ylab="Mortality rates",main="Age 65",type="l",col="red",cex=1)
lines(DataAge65$Year,DataAge65$DNB_Female/DataAge65$ENB_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="black",cex=1)
lines(DataAge65$Year,DataAge65$DNL_Female/DataAge65$ENL_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="yellow",cex=1)
lines(DataAge65$Year,DataAge65$DNTN_Female/DataAge65$ENTN_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="beige",cex=1)
lines(DataAge65$Year,DataAge65$DNS_Female/DataAge65$ENS_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="orange",cex=1)
lines(DataAge65$Year,DataAge65$DO_Female/DataAge65$EO_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="blue",cex=1)
lines(DataAge65$Year,DataAge65$DPEI_Female/DataAge65$EPEI_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="grey",cex=1)
lines(DataAge65$Year,DataAge65$DQ_Female/DataAge65$EQ_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="chocolate",cex=1)
lines(DataAge65$Year,DataAge65$DS_Female/DataAge65$ES_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="salmon",cex=1)
lines(DataAge65$Year,DataAge65$DY_Female/DataAge65$EY_Female,xlab="Year",ylab="Mortality rates",main="Age=65",type="l",col="maroon",cex=1)
#mortality age 70
plot(DataAge70$Year,DataAge70$DA_Female/DataAge70$EA_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="green",cex=1)
lines(DataAge70$Year,DataAge70$DBC_Female/DataAge70$EBC_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="blue",cex=1)
lines(DataAge70$Year,DataAge70$DM_Female/DataAge70$EM_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="red",cex=1)
lines(DataAge70$Year,DataAge70$DNB_Female/DataAge70$ENB_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="black",cex=1)
lines(DataAge70$Year,DataAge70$DNL_Female/DataAge70$ENL_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="yellow",cex=1)
lines(DataAge70$Year,DataAge70$DNTN_Female/DataAge70$ENTN_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="beige",cex=1)
lines(DataAge70$Year,DataAge70$DNS_Female/DataAge70$ENS_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="orange",cex=1)
lines(DataAge70$Year,DataAge70$DO_Female/DataAge70$EO_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="blue",cex=1)
lines(DataAge70$Year,DataAge70$DPEI_Female/DataAge70$EPEI_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="grey",cex=1)
lines(DataAge70$Year,DataAge70$DQ_Female/DataAge70$EQ_Female,xlab=”Year”,ylab=”Mortality rates”,main=”Age=70”,type=”l”,col=”chocolate”,cex=1)
lines(DataAge70$Year,DataAge70$DS_Female/DataAge70$ES_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="salmon",cex=1)
lines(DataAge70$Year,DataAge70$DY_Female/DataAge70$EY_Female,xlab="Year",ylab="Mortality rates",main="Age=70",type="l",col="maroon",cex=1)
# mortality age 75
plot(DataAge75$Year,DataAge75$DA_Female/DataAge75$EA_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="green",cex=1)
lines(DataAge75$Year,DataAge75$DBC_Female/DataAge75$EBC_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="blue",cex=1)
lines(DataAge75$Year,DataAge75$DM_Female/DataAge75$EM_Female,xlab="Year",ylab="Mortality rates",main="Age 75",type="l",col="red",cex=1)
lines(DataAge75$Year,DataAge75$DNB_Female/DataAge75$ENB_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="black",cex=1)
lines(DataAge75$Year,DataAge75$DNL_Female/DataAge75$ENL_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="yellow",cex=1)
lines(DataAge75$Year,DataAge75$DNTN_Female/DataAge75$ENTN_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="beige",cex=1)
lines(DataAge75$Year,DataAge75$DNS_Female/DataAge75$ENS_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="orange",cex=1)
lines(DataAge75$Year,DataAge75$DO_Female/DataAge75$EO_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="blue",cex=1)
lines(DataAge75$Year,DataAge75$DPEI_Female/DataAge75$EPEI_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="grey",cex=1)
lines(DataAge75$Year,DataAge75$DQ_Female/DataAge75$EQ_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="chocolate",cex=1)
lines(DataAge75$Year,DataAge75$DS_Female/DataAge75$ES_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="salmon",cex=1)
lines(DataAge75$Year,DataAge75$DY_Female/DataAge75$EY_Female,xlab="Year",ylab="Mortality rates",main="Age=75",type="l",col="maroon",cex=1)
# mortality age 80
plot(DataAge80$Year,DataAge80$DA_Female/DataAge80$EA_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="green",cex=1)
lines(DataAge80$Year,DataAge80$DBC_Female/DataAge80$EBC_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="blue",cex=1)
lines(DataAge80$Year,DataAge80$DM_Female/DataAge80$EM_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="red",cex=1)
lines(DataAge80$Year,DataAge80$DNB_Female/DataAge80$ENB_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="black",cex=1)
lines(DataAge80$Year,DataAge80$DNL_Female/DataAge80$ENL_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="yellow",cex=1)
lines(DataAge80$Year,DataAge80$DNTN_Female/DataAge80$ENTN_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="beige",cex=1)
lines(DataAge80$Year,DataAge80$DNS_Female/DataAge80$ENS_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="orange",cex=1)
lines(DataAge80$Year,DataAge80$DO_Female/DataAge80$EO_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="blue",cex=1)
lines(DataAge80$Year,DataAge80$DPEI_Female/DataAge80$EPEI_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="grey",cex=1)
lines(DataAge80$Year,DataAge80$DQ_Female/DataAge80$EQ_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="chocolate",cex=1)
lines(DataAge80$Year,DataAge80$DS_Female/DataAge80$ES_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="salmon",cex=1)
lines(DataAge80$Year,DataAge80$DY_Female/DataAge80$EY_Female,xlab="Year",ylab="Mortality rates",main="Age=80",type="l",col="maroon",cex=1)
[enter link description here][1]
如何编写代码来为这 7 个图设置一个共同的图例:我已经尝试过这段代码,但结果微不足道
legend(“topright”,legend=c(“Alberta”,”British Columbia”,”Manitoba”,”New Brunswick”,”New Foundlands”,New Terrotories”, New scotia”, “Ontario”,Prince Edouad Island”,”Quebec”, “SaKastchewan””Yukon”),cex=0.8,fill.colors)
请你能帮我改进我的代码吗?