scale_x_date以及如何使其等距?
如何使用ggplot2软件包或其他任何包裹在造成的几个月之间删除“空白”我的X轴缺少某些月?换句话说,使X轴看起来是等距的,而没有那些“空白的镜头”。通过代码非常正常,它是关于绘制某些值与包含日期的其他列(并非所有月份都存在于该日期列中)。
filtredplot1<-reactive({
req(res_mod())
dat<-res_mod()
dt<-dat[dat$M_Datum >= input$dateRange[1] & dat$M_Datum <= input$dateRange[2],]
dt[,5]<-as.Date(format(as.Date(dt[,5]), "%Y-%m-01"))
req(dt$M_Datum,dt$Yield)
dr<-data.frame("M_Datum"=dt$M_Datum,"Yield"=dt$Yield)
mydf=aggregate(Yield ~ M_Datum, dr, length)
req(mydf$M_Datum,mydf$Yield)
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")+
scale_x_date(labels="%b %Y")
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("")
})
How can please using ggplot2 package or whatever else package remove that "blank space " between months caused by absence of certain months on my x axis ? In other words to make the x axis looks equidistant and not having those "blank gapes".By the code is very normal ,it is about plotting certain values vs other column containing dates (not all the months are present in that date column ).
filtredplot1<-reactive({
req(res_mod())
dat<-res_mod()
dt<-dat[dat$M_Datum >= input$dateRange[1] & dat$M_Datum <= input$dateRange[2],]
dt[,5]<-as.Date(format(as.Date(dt[,5]), "%Y-%m-01"))
req(dt$M_Datum,dt$Yield)
dr<-data.frame("M_Datum"=dt$M_Datum,"Yield"=dt$Yield)
mydf=aggregate(Yield ~ M_Datum, dr, length)
req(mydf$M_Datum,mydf$Yield)
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")+
scale_x_date(labels="%b %Y")
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)
下面的代码不会创建数据。FRAMES
DR
和mydf
,您的数据准备代码太复杂了。以下要简单得多,并且可以工作。另外,您在代码中两次具有
your
的错字yiel
。第一个创建koka
和aes()
中的第二个时。The code below does not create the data.frames
dr
andmydf
, your data preparation code is too complicated. The following is much simpler and works.Also, you have the typo
Yiel
forYield
twice in your code. The first when creatingkoka
and the second inaes()
.