小编use*_*557的帖子

R ggplot Y轴中断设置

我在代码中设置中断时遇到了困难,我尝试添加break = seq(0,100,by = 20),但似乎无法让它正常工作.基本上我希望Y轴从0到100,每20个刻度.

    YearlyCI <- read.table(header=T, text='
  Station Year       CI        se
     M-25 2013 56.57098 1.4481561
     M-45 2013 32.39036 0.6567439
      X-2 2013 37.87488 0.7451653
     M-25 2008     74.5       2.4
     M-45 2008     41.6       1.1
     M-25 2004     82.2       1.9
     M-45 2004     60.6       1.0
     ')


library(ggplot2)
ggplot(YearlyCI, aes(x=Year, y=CI, colour=Station,group=Station)) +
  geom_errorbar(aes(ymin=CI-se, ymax=CI+se), colour="black", width=.2) +
  geom_line(size=.8) +
  geom_point(size=4, shape=18) +
  coord_cartesian(ylim = c(0, 100)) +
  xlab("Year") +
  ylab("Mean Condition Index") +
  labs(fill="") +
  theme_bw() +
    theme(legend.justification=c(1,1), legend.position=c(1,1)) 
Run Code Online (Sandbox Code Playgroud)

r ggplot2

12
推荐指数
1
解决办法
5万
查看次数

躲避误差线和点以避免重叠

我正在尝试修复错误栏,以便它们在我的图表上实际上是可读的。唯一引起问题的是 2013 年的数据。我该怎么做?我看到了一些关于抖动或闪避的帖子,但我不确定如何应用它来解决我的问题。

这是我试图改变的代码:

YearlyDensity <- read.table(header=T, text='
Station Year       mean           se
   M-25 2013   8944.444     3636.871
   M-25 2008       4212         2371
   M-25 2004        963          291
   M-45 2013   8495.169     2111.072
   M-45 2008      13023         1347
   M-45 2004       8748         1740
    X-2 2013  12345.411     1166.905
')    

library(ggplot2)
ggplot(YearlyDensity, aes(x=Year, y=mean, colour=Station,group=Station)) +
  geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.2) +
  geom_line(size=.8) +
  geom_point(size=4, shape=18) +
  coord_cartesian(ylim = c(0, 16000)) +
  scale_y_continuous(breaks=seq(0,16000,2000)) +
  xlab("Sampling Year") +
  ylab("Mean Density") +
  labs(fill="") +
  theme_bw() +
    theme(legend.justification=c(1,0), legend.position=c(1,0))
Run Code Online (Sandbox Code Playgroud)

r ggplot2 errorbar

8
推荐指数
1
解决办法
9864
查看次数

标签 统计

ggplot2 ×2

r ×2

errorbar ×1