ggplot2의 피라미드 막대 그림에 레이블 정렬

Sunny Avry

내 ggplot 그래프의 각 막대에 숫자를 정렬하는 데 성공하지 못했습니다. 또 다른 문제는 범례 위에있는 "채우기"메시지를 제거하고 싶지만 어떻게 나타나는지 이해하지 못한다는 것입니다. 당신의 도움을 주셔서 감사합니다.

graph <- ggplot(df, aes(x=labs)) +
  geom_bar(data=df[df$isEmotion=="emotion",], aes(y=RTU, fill = "Emotion"), stat="identity") +
  geom_bar(data=df[df$isEmotion=="no emotion",], aes(y=-RTU, fill = "No Emotion"), stat="identity") +
  geom_hline(yintercept=0, colour="white", lwd=1) +
  theme(text = element_text(size=15)) +
  coord_flip(ylim=lim) + 
  scale_y_continuous(breaks=breaks, labels=labels) +
  labs(y="RTU", x="Collaborative acts") +
  ggtitle("               Interested") +
  geom_text(aes(label = round(RTU), y=RTU))

데이터:

변수:

lim = c(-1.6,1.6)
breaks = seq(-1.6,1.6,0.4)
labels = c(1.6,1.2,0.8,0.4,0,0.4,0.8,1.2,1.6)

다음을 통한 데이터 테이블 dput:

structure(list(labs = structure(c(29L, 28L, 27L, 26L, 25L, 24L, 
23L, 22L, 21L, 20L, 19L, 18L, 17L, 16L, 15L, 14L, 13L, 12L, 11L, 
10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L, 29L, 28L, 27L, 26L, 
25L, 24L, 23L, 22L, 21L, 20L, 19L, 18L, 17L, 16L, 15L, 14L, 13L, 
12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L), .Label = c("Show Hostility", 
"Elicit Recall", "Check Comprehension", "Refuse", "Show Solidarity", 
"Give Explanation", "Elicit Proposition", "Incorporate", "Use Social Convention", 
"Elicit Partner Information", "Outside Activity", "Give Opinion Against", 
"Coordinate Teamwork", "Check Reception", "Elicit Task Information", 
"Show Active Listening", "Elicit Opinion", "Give Recall", "Give Task Information", 
"Give Self Information", "Relax Atmosphere", "Manage Task", "Give Proposition", 
"Tool Discourse", "Show Reflection", "Accept", "Agree", "Other", 
"Give Opinion For"), class = "factor"), RTU = c(1.33679949277407, 
1.113629906839, 0.998523521750659, 0.774259935575577, 0.659963240986954, 
0.60839106356628, 0.6065649859483, 0.539489093267195, 0.480274995783261, 
0.423104935724923, 0.408927591199088, 0.274223979504919, 0.270110544387821, 
0.258935589229039, 0.218353068762815, 0.193643374161986, 0.177004182065326, 
0.102980320541176, 0.0980838299538663, 0.0969015258673401, 0.0734178878735949, 
0.0649985993746002, 0.054594994045725, 0.0404505716411595, 0.0345846135809401, 
0.0344802024462216, 0.0311026889658307, 0.0245605273402327, 0.00164473684210526, 
0.798245614035088, 0.631578947368421, 0.87719298245614, 1.21052631578947, 
0.657894736842105, 0.526315789473684, 0.56140350877193, 0.508771929824561, 
0.543859649122807, 0.473684210526316, 0.587719298245614, 0.236842105263158, 
0.254385964912281, 0.333333333333333, 0.280701754385965, 0.368421052631579, 
0.333333333333333, 0.175438596491228, 0.0175438596491228, 0.0701754385964912, 
0.184210526315789, 0.0175438596491228, 0.114035087719298, 0.0789473684210526, 
0, 0, 0.105263157894737, 0.0526315789473684, 0), isEmotion = c("no emotion", 
"no emotion", "no emotion", "no emotion", "no emotion", "no emotion", 
"no emotion", "no emotion", "no emotion", "no emotion", "no emotion", 
"no emotion", "no emotion", "no emotion", "no emotion", "no emotion", 
"no emotion", "no emotion", "no emotion", "no emotion", "no emotion", 
"no emotion", "no emotion", "no emotion", "no emotion", "no emotion", 
"no emotion", "no emotion", "no emotion", "emotion", "emotion", 
"emotion", "emotion", "emotion", "emotion", "emotion", "emotion", 
"emotion", "emotion", "emotion", "emotion", "emotion", "emotion", 
"emotion", "emotion", "emotion", "emotion", "emotion", "emotion", 
"emotion", "emotion", "emotion", "emotion", "emotion", "emotion", 
"emotion", "emotion", "emotion")), row.names = c(NA, -58L), class = "data.frame")

음모:

음모

dc37

범례 제목을 제거하려면 함수를 사용할 수 있습니다 labs(fill = ""). 당신이 geom_bar을 위해했던 것처럼, 당신의 피라미드에 대한 라벨을 정렬 들어, 두 개의 라인 통과해야 geom_text, 그룹의 레이블 하나 emotion(y는 RTU를 =) 및 그룹의 레이블을 no emotion(함께 Y = -RTU) . hjust각각을 조정 하여 플롯에서 예쁘게 만들 수 있습니다.

ggplot(df, aes(x = labs)) +
  geom_bar(data = ~subset(., isEmotion=="emotion"), aes( y = RTU, fill = "Emotion"), stat = "identity") +
  geom_bar(data = ~subset(., isEmotion=="no emotion"), aes(y = -RTU, fill = "No Emotion"), stat = "identity") +
  geom_hline(yintercept=0, colour="white", lwd=1) +
  theme(text = element_text(size=15)) +
  coord_flip(ylim=lim) + 
  scale_y_continuous(breaks=breaks, labels=labels) +
  labs(y="RTU", x="Collaborative acts") +
  ggtitle("               Interested") +
  geom_text(data = ~subset(., isEmotion=="emotion"), aes(label = round(RTU, digits = 2), y = RTU), hjust = -0.75) +
  geom_text(data = ~subset(., isEmotion=="no emotion"), aes(label = round(RTU, digits = 2), y = -RTU), hjust = 1.5)+
  labs(fill = "")

여기에 이미지 설명 입력

귀하의 질문에 대한 답변을 바랍니다!

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

ggplot2의 누적 막대 그림에 대한 요인 재정렬

분류에서Dev

막대 차트 ggplot2의 레이블 조정, 데이터 값에 종속되지 않음

분류에서Dev

ggplot2의 막대 그림 상단에 레이블이없는 눈금 추가

분류에서Dev

다중 x 축 ggplot2 또는 사용자 정의 레이블을 스택 막대 플롯에 추가

분류에서Dev

그룹화 된 막대 그림의 ggplot 레이블 막대

분류에서Dev

ggplot2의 막대 그림을 사용하여 작동하지 않는 그룹 내에서 재정렬

분류에서Dev

양수 및 음수 막대가있는 값의 수로 막대 그림에 레이블 지정

분류에서Dev

인구 피라미드에서 레이블 위치 변경 (ggplot2)

분류에서Dev

ggplot2의 비례 누적 막대 차트에 대한 절대 레이블

분류에서Dev

ggplot2의 비례 누적 막대 차트에 대한 절대 레이블

분류에서Dev

ggplot2를 사용하여 막대 그림에 레이블을 지정하는 방법은 무엇입니까?

분류에서Dev

ggplot2 : 채우기 변수의 비율에 따라 누적 막대 차트를 재정렬하는 방법

분류에서Dev

R ggplot2 facet_wrap 하위 그림 재정렬 및 각 ID 레이블에 대해 다른 색상 설정

분류에서Dev

ggplot2에서 그룹화 된 막대 그림 열에 레이블을 배치하는 방법

분류에서Dev

R의 피라미드 형 (직각이 아닌) 누적 막대 그래프

분류에서Dev

누적 막대 그림에 레이블 지정

분류에서Dev

숫자 값에 따라 ggplot2의 x 축 레이블 순서 지정

분류에서Dev

숫자 값에 따라 ggplot2의 x 축 레이블 순서 지정

분류에서Dev

geom_bar ggplot2 양수 및 음수 값이있는 누적, 그룹화 된 막대 플롯-피라미드 플롯

분류에서Dev

ggplot2 R 3.0.3에서 막대 레이블 추가

분류에서Dev

ggplot2 barplot R에서 수직 막대의 약간의 오정렬

분류에서Dev

혼합 문자 및 숫자 변수로 ggplot2 막대 그림 재정렬

분류에서Dev

ggplot2 생성 누적 막대 그래프에서 막대 순서 정의

분류에서Dev

ggplot2에서 정렬 된 막대 그림에 빈도 백분율을 추가하는 방법

분류에서Dev

ggplot2의 이중 막대 그래프에 선 추가

분류에서Dev

열의 값으로 정규화 된 R ggplot2 누적 막대 그림

분류에서Dev

ggplot2 값으로 막대 그래프 정렬

분류에서Dev

ggplot2 히스토그램 : 각 막대의 시작 부분에 레이블 표시

분류에서Dev

ggplot2에서 그리드 정렬 및 변수 이름에 대한 ylabs 수정

Related 관련 기사

  1. 1

    ggplot2의 누적 막대 그림에 대한 요인 재정렬

  2. 2

    막대 차트 ggplot2의 레이블 조정, 데이터 값에 종속되지 않음

  3. 3

    ggplot2의 막대 그림 상단에 레이블이없는 눈금 추가

  4. 4

    다중 x 축 ggplot2 또는 사용자 정의 레이블을 스택 막대 플롯에 추가

  5. 5

    그룹화 된 막대 그림의 ggplot 레이블 막대

  6. 6

    ggplot2의 막대 그림을 사용하여 작동하지 않는 그룹 내에서 재정렬

  7. 7

    양수 및 음수 막대가있는 값의 수로 막대 그림에 레이블 지정

  8. 8

    인구 피라미드에서 레이블 위치 변경 (ggplot2)

  9. 9

    ggplot2의 비례 누적 막대 차트에 대한 절대 레이블

  10. 10

    ggplot2의 비례 누적 막대 차트에 대한 절대 레이블

  11. 11

    ggplot2를 사용하여 막대 그림에 레이블을 지정하는 방법은 무엇입니까?

  12. 12

    ggplot2 : 채우기 변수의 비율에 따라 누적 막대 차트를 재정렬하는 방법

  13. 13

    R ggplot2 facet_wrap 하위 그림 재정렬 및 각 ID 레이블에 대해 다른 색상 설정

  14. 14

    ggplot2에서 그룹화 된 막대 그림 열에 레이블을 배치하는 방법

  15. 15

    R의 피라미드 형 (직각이 아닌) 누적 막대 그래프

  16. 16

    누적 막대 그림에 레이블 지정

  17. 17

    숫자 값에 따라 ggplot2의 x 축 레이블 순서 지정

  18. 18

    숫자 값에 따라 ggplot2의 x 축 레이블 순서 지정

  19. 19

    geom_bar ggplot2 양수 및 음수 값이있는 누적, 그룹화 된 막대 플롯-피라미드 플롯

  20. 20

    ggplot2 R 3.0.3에서 막대 레이블 추가

  21. 21

    ggplot2 barplot R에서 수직 막대의 약간의 오정렬

  22. 22

    혼합 문자 및 숫자 변수로 ggplot2 막대 그림 재정렬

  23. 23

    ggplot2 생성 누적 막대 그래프에서 막대 순서 정의

  24. 24

    ggplot2에서 정렬 된 막대 그림에 빈도 백분율을 추가하는 방법

  25. 25

    ggplot2의 이중 막대 그래프에 선 추가

  26. 26

    열의 값으로 정규화 된 R ggplot2 누적 막대 그림

  27. 27

    ggplot2 값으로 막대 그래프 정렬

  28. 28

    ggplot2 히스토그램 : 각 막대의 시작 부분에 레이블 표시

  29. 29

    ggplot2에서 그리드 정렬 및 변수 이름에 대한 ylabs 수정

뜨겁다태그

보관