在X轴是日期的因素的命令或对X轴上排序?
dt<-data.frame(M_Datum=c("2018-02-05","2018-02-15","2018-02-10","2018-02-13","2017-02-05","2017-02-15","2017-02-10","2017-02-23","2020-02-25","2012-02-15","2020-02-10","2020-02-13"),Yield=c(4,47,18,10,22,50,70,120,150,400,60,78))
dt[,1]<-as.Date(format(as.Date(dt[,1]), "%Y-%m-01"))
dr<-data.frame("M_Datum"=dt$M_Datum,"Yield"=dt$Yield)
mydf=aggregate(Yield ~ M_Datum, dr, length)
koka<-data.frame("M_Datum"=mydf$M_Datum,"Yiel"=mydf$Yield)
ggplot(koka, aes(x=factor(format(M_Datum, "%b %Y")), y=Yiel,group = 1)) +
geom_point(size=7,colour="#EF783D",shape=17) +
geom_line(color="#EF783D")+
theme(axis.text.x = element_text(angle = 0, vjust = 0.5, hjust=1))+
theme(axis.text.y.left = element_text(color = "#EF783D"),
axis.title.y.left = element_text(color = "#EF783D"))+
ylab("Wafer Quantity")+
xlab("")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要按正确的顺序将因子的水平放置。您可以对此
有点混乱,因此您可以编写一个辅助功能来清理,
从而导致以下图
You will need to put the levels of the factor in the correct order. You can do that with
Which is a bit messy so you could write a helper function to clean up up
That results in the following plot