Ggplot可视化改进

Ggplot visualization improve

我有一个 Bici 服务的数据框,它看起来像这样,其中 Origen_Id 是站号,Num_Viaje_Ori 是从该站开始的行程总数。

Origen_Id Num_F Num_M Num_Viaje_Ori Destino_Id Num_F_d Num_M_d Num_Viaje_Des
11 1616 3973 5589 11 139 5 3855 5250
34 962 3232 4194 34 1340 4236 5576
35 1321 3993 5314 35 1418 4239 5657
50 1797 4293 6090 50 1785 4314 6099
51 1891 5186 7077 51 3084 7771 10855
52 1379 4320 5699 52 1299 3913 5212
54 1275 3950 5225 54 1373 4046 5419
75 1332 2939 4271 75 1202 2763 3965
194 1346 3792 5138 194 632 1845 2477
271 1511 3640 5151 271 1483 3750 5233

当我运行

s<-ggplot(most, aes(x=Origen_Id, y=Num_Viaje_Ori))+geom_bar(stat="identity")

我得到了

我该如何解决?我的意思是,我怎样才能使栏杆靠得更近?

执行评论的建议,你应该得到:

library(tidyverse)
library(tibble)
library(ggthemes)

most <- 
  tibble::tribble(
  ~Origen_Id, ~Num_F, ~Num_M, ~Num_Viaje_Ori, ~Destino_Id, ~Num_F_d, ~Num_M_d, ~Num_Viaje_Des,
         11L,  1616L,  3973L,          5589L,         11L,     139L, "5 3855",          5250L,
         34L,   962L,  3232L,          4194L,         34L,    1340L,   "4236",          5576L,
         35L,  1321L,  3993L,          5314L,         35L,    1418L,   "4239",          5657L,
         50L,  1797L,  4293L,          6090L,         50L,    1785L,   "4314",          6099L,
         51L,  1891L,  5186L,          7077L,         51L,    3084L,   "7771",         10855L,
         52L,  1379L,  4320L,          5699L,         52L,    1299L,   "3913",          5212L,
         54L,  1275L,  3950L,          5225L,         54L,    1373L,   "4046",          5419L,
         75L,  1332L,  2939L,          4271L,         75L,    1202L,   "2763",          3965L,
        194L,  1346L,  3792L,          5138L,        194L,     632L,   "1845",          2477L,
        271L,  1511L,  3640L,          5151L,        271L,    1483L,   "3750",          5233L
  )

most %>% 
  mutate(Origen_Id = as.factor(Origen_Id)) %>% 
  ggplot(aes(x=Origen_Id, y=Num_Viaje_Ori)) +
  geom_col(fill = "darkslateblue") + 
  ggthemes::theme_economist_white()

reprex package (v2.0.1)

于 2021-11-23 创建