简体   繁体   中英

Space between bar chart with day/week/month in x axis in R

When the number of bars is large (when days/weeks are on x axis), the spaces between the bars are not visible. 参考这个条形图

But when the number of bars are small (when months are on x axis), the spaces between the bars are vsiible. 请参阅此条形图

What i want is irrespective of number of bars, the spaces between the bars should be visible. Any idea to code in R please?

You could add colour = "white" for the border around the bars:

library(tidyverse)

df <- tibble(x = rep(1:100, 5)) 

df |> 
  ggplot(aes(x)) +
  geom_histogram()
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

df |> 
  ggplot(aes(x)) +
  geom_histogram(colour = "white")
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2022-05-17 by the reprex package (v2.0.1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM