2016-09-28 3 views
0

이것은 내 입장에서 정말 어리석은 실수로 보일 수 있지만 요인에 따라 geom_point를 지정하고 중공 점과 솔리드 점 (모양 1과 19) 및 플롯 오류 막대 , 그것은 지점을 교차합니다.geom_point가 실제로 비어 있지 않습니다. 오류 막대가 겹치지 않습니다

> dput(head(allbins.sum)) 
structure(list(T = c(0L, 0L, 10L, 10L, 20L, 20L), treatment = structure(c(1L, 
2L, 1L, 2L, 1L, 2L), .Label = c("control bead", "dP bead"), class = "factor"), 
    N = c(3, 3, 3, 3, 3, 3), cellsBase = c(0, 0, 0.013028995209506, 
    0.135599858885737, -0.0130289952095061, 0.759359209760127 
    ), sd = c(0, 0, 0.0597063567767786, 0.0469731690178533, 0.0983667566897066, 
    0.183436089048999), se = c(0, 0, 0.034471481157405, 0.0271199717771474, 
    0.0567920734541125, 0.105906875391532), ci = c(0, 0, 0.148318812500416, 
    0.116687820597672, 0.244356569875469, 0.455680506502609), 
    bin = c("BinA", "BinA", "BinA", "BinA", "BinA", "BinA")), .Names = c("T", 
"treatment", "N", "cellsBase", "sd", "se", "ci", "bin"), row.names = c(NA, 
6L), class = "data.frame") 

> dput(head(allbins.fitdata)) 
structure(list(wellvidbin = structure(c(1L, 1L, 1L, 1L, 1L, 1L 
), .Label = c("A1-002-BinA", "A1-002-BinB", "A1-002-BinC", "A1-031-BinA", 
"A1-031-BinB", "A1-031-BinC", "A3-004-BinA", "A3-004-BinB", "A3-004-BinC", 
"B1-032-BinA", "B1-032-BinB", "B1-032-BinC", "B4-026-BinA", "B4-026-BinB", 
"B4-026-BinC", "C4-027-BinA", "C4-027-BinB", "C4-027-BinC"), class = "factor"), 
    treatment = structure(c(2L, 2L, 2L, 2L, 2L, 2L), .Label = c("control bead", 
    "dP bead"), class = "factor"), wellvid = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L), .Label = c("A1-002", "A1-031", "A3-004", 
    "B1-032", "B4-026", "C4-027"), class = "factor"), bin = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L), .Label = c("BinA", "BinB", "BinC"), class = "factor"), 
    T = c(0L, 10L, 20L, 30L, 40L, 50L), T.factor = structure(1:6, .Label = c("0", 
    "10", "20", "30", "40", "50", "60"), class = "factor"), cells = c(7L, 
    11L, 26L, 27L, 28L, 36L), cellsS = c(-1.36568429306349, -1.20296446240061, 
    -0.592765097414793, -0.552085139749072, -0.511405182083351, 
    -0.185965520757582), cellsBase = c(0, 0.162719830662884, 
    0.772919195648701, 0.813599153314422, 0.854279110980143, 
    1.17971877230591), treatT = structure(c(2L, 4L, 6L, 8L, 10L, 
    12L), .Label = c("control bead.0", "P bead.0", "control bead.10", 
    "P bead.10", "control bead.20", "P bead.20", "control bead.30", 
    "P bead.30", "control bead.40", "P bead.40", "control bead.50", 
    "P bead.50", "control bead.60", "P bead.60"), class = "factor"), 
    fit = c(0.0285939715820639, 0.304399288764407, 0.58020460594675, 
    0.856009923129092, 1.13181524031144, 1.40762055749378), se.fit = c(0.157415367032567, 
    0.132348142293459, 0.114707848741265, 0.108190467052118, 
    0.114707848741265, 0.132348142293459), upr = c(0.337128090965895, 
    0.563801647659587, 0.805031989479629, 1.06806323855124, 1.35664262384431, 
    1.66702291638896), lwr = c(-0.279940147801767, 0.0449969298692267, 
    0.35537722241387, 0.643956607706942, 0.906987856778556, 1.1482181985986 
    )), .Names = c("wellvidbin", "treatment", "wellvid", "bin", 
"T", "T.factor", "cells", "cellsS", "cellsBase", "treatT", "fit", 
"se.fit", "upr", "lwr"), class = c("data.table", "data.frame" 
), row.names = c(NA, -6L), .internal.selfref = <pointer: 0x0000000000100788>) 

그리고 코드 : 여기

내 데이터 프레임이다

ggplot(data=allbins.sum, aes(x=T, y=cellsBase, shape=treatment)) + geom_point(size=5, aes(shape=treatment))+ 
    geom_errorbar(aes(ymin=cellsBase-se, ymax=cellsBase+se), width=2, size=1) + 
    geom_smooth(data=allbins.fitdata, size=1, aes(y=fit, ymin=lwr, ymax=upr), 
       color="black", method="lm", stat="identity", alpha=0.2)+ 
    facet_grid(bin~.) + 
    scale_shape_manual(values=c(1, 19)) 

이 나에게이 플롯 제공 :에 중공 원을하는 방법에 대한 enter image description here

어떤 힌트를 속이 비? 또한 다음 geom_shape (aes(fill=treatment)scale_fill_manual를 지정하려하지만 그것은 또한 도움을 내 geom_smooth

감사에 적용됩니다!

+1

을 "속이 빈 동그라미"*? 그들은 이미 충분히 비어 있지 않은가? – Jaap

답변

3

'빈'점을 통해 오류 막대의 선을 표시하지 않으려면 geom_errorbar을 먼저 그립니다. 단색 채우기로 geom_point 초를 그려야하므로 오류 막대가 오버레이됩니다 . *

enter image description here

ggplot(data=allbins.sum, aes(x=T, y=cellsBase)) + 
    # plotting this first 
    geom_errorbar(aes(ymin=cellsBase-se, ymax=cellsBase+se), width=2, size=1) + 

    # plotting this second, with a hollow fillable shape, and black outline 
    geom_point(size=5, shape = 21, color='black', 
      aes(fill = treatment)) + 

    # solid black and solid white fill for the points 
    scale_fill_manual(values = c('black', 'white')) + 
    theme_bw() 
은 (만 게시 된 데이터는 allbins.sum 이러한 점을 가지고 있으며, allbins.fitdata에 대한 코드는 오류이 음모에 이렇게 오류 바있다) 당신이 무슨 뜻 이죠

+1

ggplot이 geom을 레이어별로 추가한다는 사실을 완전히 잊어 버렸습니다! 감사! – Kaye11

관련 문제