0

所以我有一个情节需要我很长时间才能制作出来。它需要指定月份并且既是线又是点,如下所示:

在此处输入图像描述

但是,我收到此错误消息,并且“九月”并未显示为一个点。

警告消息:1:删除了 1 行包含缺失值 (geom_path)。2:删除了 1 行包含缺失值 (geom_point)。

这是我的情节的代码:

ggplot(Rate_time, aes (x=Month, y = Rate)) + 
  geom_line(aes(group=1), colour = "Orange") + 
  geom_point(colour = "Orange") + 
  theme_classic() + 
  scale_x_discrete(limits = month.abb) + 
  labs (y = "Rate (%)", x = "Month (2019)") + 
  theme(axis.text.x = element_text(colour = "black")) + 
  theme(axis.text.y = element_text(colour = "black")) + 
  theme(text=element_text(size=11,family="serif")) + 
  scale_y_continuous(limits=c(0,0.25))

数据如下所示: 在此处输入图像描述

我目前没有代码格式的数据,但如果需要,可以这样做。我尝试过扩展 y 轴,但没有运气。我不确定如何处理此错误,同时将月份保留为单词而不是数字。

任何帮助,将不胜感激 :)

4

1 回答 1

0

R 没有将“Sept”识别为 9 月。尝试改用“Sep”。

set.seed(123)
#Works as is
Rate_time<- data.frame(Month=month.abb, Rate=runif(12, 0, 0.25))


#add this line to reproduce your problem.
#changes Sep to Sept
#Rate_time$Month[9] <- "Sept"

ggplot(Rate_time, aes (x=Month, y = Rate)) + 
   geom_line(aes(group=1), colour = "Orange") + 
   geom_point(colour = "Orange") + 
   theme_classic() + 
   scale_x_discrete(limits = month.abb) + 
   labs (y = "Rate (%)", x = "Month (2019)") + 
   theme(axis.text.x = element_text(colour = "black")) + 
   theme(axis.text.y = element_text(colour = "black")) + 
   theme(text=element_text(size=11,family="serif")) + 
   scale_y_continuous(limits=c(0,0.25))
于 2021-03-09T23:12:20.447 回答