각 막대 그림 위에 오류 막대를 만들려고하지만 3 개의 그룹과 6 개의 막대 그래프로 막대 그래프가 있으며 각 막대와 관련하여 오류 막대를 배치합니다. 각 오차 막대가 각 막대 위에 있으면 위치 지정.gg 플롯 오류 막대 배치
newData의
Group Session HeartRate StdError n sd
1 Novices one 71.89276 1.821146 29 9.807170
2 Experts one 66.40705 1.923901 26 9.810008
3 Novices two 71.38609 1.571261 29 8.011889
4 Experts two 67.79910 1.788151 26 9.117818
5 Novices three 71.79759 1.941730 29 10.456534
6 Experts three 67.04564 1.938620 26 9.885061
그리고 여기 내 코드입니다 :
plot_2 = ggplot(NewData, aes(x=Session, y=HeartRate, fill=Group)) +
theme_bw() +
geom_bar(position="dodge",stat="identity")+
scale_x_discrete(limits=c("one","two","three")) +
coord_cartesian(ylim = c(50, 80)) +
geom_errorbar(aes(ymin=HeartRate-StdError,ymax=HeartRate+StdError),position="dodge",width=.25)
여기 출력입니다 : 어떤 도움을 주시면 감사하겠습니다 http://i.imgur.com/BrLB6Px.png
여기 내 데이터처럼 보이는거야. 감사!
OK-- 나는 정말 확실하지 않은 해결책을 발견하는 방법 또는 여기에 작동하지만, 왜 내 새로운 코드입니다 :
dodge <- position_dodge(width=0.9)
plot_2 = ggplot(NewData, aes(x=Session, y=HeartRate, fill=Group)) +
geom_bar(position=dodge)+
scale_x_discrete(limits=c("one","two","three")) +
coord_cartesian(ylim = c(50, 80)) +
geom_errorbar(aes(ymin=HeartRate-StdError,ymax=HeartRate+StdError),position=dodge,width=.25)
그리고 여기에 원하는 결과입니다 :에 하드 http://i.imgur.com/PodCeh5.png
난 당신이하고자 이해 y 축이 50에서 시작하지만, [Ben Bolker 's answer here] (http://stackoverflow.com/questions/11695502/different-starting-point-not-0-in-barplot-y-axis)를 읽을 수 있습니다./11695689 # 11695689) 인수가 0을 포함하는 축이없는 것에 대한 것입니다. 나는 여기에 'scale_x_discrete'가 필요하다고 생각하지 않는다. – Henrik