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

Time:05-18

When the number of bars is large (when days/weeks are on x axis), the spaces between the bars are not visible. Refer this bar plot

But when the number of bars are small (when months are on x axis), the spaces between the bars are vsiible. Refer tthis bar plot

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

CodePudding user response:

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)

  • Related