在图上添加图例

时间:2019-10-19 19:53:13

标签: r ggplot2

当我尝试绘制折线图时,我得到了相同的消息:

  

strwidth错误(传奇,单位=“用户”,cex = cex,字体= text.font)   :plot.new尚未被调用

我正在使用R降价促销,不确定是否会有所不同

ggplot(accident, aes(x=year)) +                    
  geom_line(aes(y=major_accident), colour="dark green", size=1) +  
  geom_line(aes(y=`serious accident`), colour="red", size=1.3)+
  scale_y_discrete("Accident Fatality", limits=c(0,2,4,6,8,10))+
  scale_x_discrete("year", limits=c(1985, 1990, 1995, 2000, 2005, 2010))+
  ggtitle("Major Accidents versus Serious Accidents for Under 14 CFR 121 US carriers")+
  theme_grey()+    
  legend(2010, 8, 
         c("major_accident", "`serious accident`", 
           lty=c(1,1), lwd=c(2.5,2.5), 
           col=c("dark green", "red")))

0 个答案:

没有答案
相关问题