为什么这些实线出现在我的 ggplot 绘图下方?

Mic*_*nti 2 r ggplot2 facet-wrap dplyr

在此输入图像描述

这是我的代码:

pokemon <- read_csv("https://uwmadison.box.com/shared/static/hf5cmx3ew3ch0v6t0c2x56838er1lt2c.csv")

pokemon %>%  
  select(Name, type_1, Attack, Defense) %>% 
  mutate(AttDefRatio = Attack/Defense) %>% 
  ggplot(
    aes(Name, AttDefRatio)
  ) +
  geom_point(size = 0.5) +
  facet_wrap(type_1 ~ .) +
  theme(legend.position = "bottom")
Run Code Online (Sandbox Code Playgroud)

对于这个家庭作业,我们正在使用分面,一切看起来都应该是这样的,但是在图的底部有两条粗线。如果有人知道为什么会发生那就太棒了!

And*_*own 6

这两行实际上是 x 轴标签,但您可以使用以下命令删除它们axis.text.x=element_blank()

pokemon %>%  
    select(Name, type_1, Attack, Defense) %>% 
    mutate(AttDefRatio = Attack/Defense) %>% 
    ggplot(
        aes(Name, AttDefRatio)
    ) +
    geom_point(size = 0.5) +
    facet_wrap(type_1 ~ .) +
    theme(legend.position = "bottom", axis.text.x=element_blank())
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Names或者,如果您想通过设置为free_xin来显示个人facet_wrap,请更改 中的文本大小theme。尽管在一张图表上显示大量信息并且很难看到。

pokemon %>%  
  select(Name, type_1, Attack, Defense) %>% 
  mutate(AttDefRatio = Attack/Defense) %>% 
  ggplot(
    aes(Name, AttDefRatio)
  ) +
  geom_point(size = 0.5) +
  facet_wrap(type_1 ~ ., ncol = 5, scales = "free_x") +
  theme(legend.position = "bottom", axis.text.x=element_text(angle = 90, vjust = 0.5, hjust=1, size = 3))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述