질문게시판

Titlegeom_text 창 작게해도 보이게 하는 방법2022-11-09 11:28
Name Level 1

dat1 %>%
  group_by(wwa1gp, sexgp) %>%
  count(sleepgp) %>%
  mutate(prob = n/sum(n)*100,
         prob = round(prob, 1)) %>%
  filter(sleepgp =="1.sleep disturbance") %>%
  ggplot(aes(x=wwa1gp, y = prob)) +
  xlab("Kept worrying about work when you were not working") +
  ylab("Sleep Disturbance (proportion)") +
  geom_bar(stat="identity") +
  geom_text(aes(label = sprintf("%s%%", prob)), vjust = -0.5) +
  scale_y_continuous(labels = function(x) sprintf("%s%%", round(x))) +
  facet_grid(.~sexgp) +
  geom_text(
    data = dat_text,
    mapping =aes(x= -Inf, y= -Inf, label=label),

# hjust, vjust대신 x와 y의 축으로 지정
    x = 2, y = 20, # 그래프 안의 (2,20)에 글자가 작성됩니다.
    family="Times"
  ) +
  theme_minimal() +
  theme(text=element_text(family="Times New Roman", face="bold", size=12))
help(geom_text)
 

 

Comment
Captcha Code
(Enter the auto register prevention code)