简体   繁体   English

标签y轴变化

[英]Labels y-axis change

I struggling a lot with a graph and I dont know what is going wrong. 我在图上挣扎很多,我不知道出了什么问题。 I got the following dataframe: 我得到以下数据框:

And then I use the following dataframe: 然后,我使用以下数据框:

df <- read.table(text ="YEAR Eucaris Niet.Eucaris
1    8   81867    0.1527756
2    9   91507    0.1533734
3   10  102755    0.1733875
4   11  116491    0.1648633
5   12   55133    0.1771800
6   13   67115    0.1449571", header =TRUE)

This works but when I expand the dataframe 这有效,但是当我扩展数据框时

r <- c(14,56849)
df <- rbind(df, r)

The graph shows 8, 10, 12 in stead of 8,9,10 etc... 该图显示了8、10、12而不是8、9、10等。

Why is this happening? 为什么会这样呢?

Using ggplot2 , by modifying scale_x_continuous : 使用ggplot2 ,通过修改scale_x_continuous

library(ggplot2)
graph <- ggplot(df, aes(x = YEAR, y=Eucaris)) + 
  geom_line(linetype="dashed", size=1, colour="blue") + 
  geom_point(size=4, shape=22, colour="darkred", fill="pink")+
  scale_x_continuous(breaks = 1:14)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM