Home > Enterprise >  R correction of plot
R correction of plot

Time:11-03

I have a code to plot histogram in R that works fine:

fun_hist <- function(c, E, HS, log_EC_50) {
  df <- data.frame(log_c = c, response = V({{c}}, {{E}}, {{HS}}, {{log_EC50}}))
  ggplot2::ggplot(df, aes( response))    geom_histogram(binwidth=0.03)
}

I want to correct my histogram so that its bars have a graphic design as in the attached photo.

plot

CodePudding user response:

This looks pretty similar to my eye:

library(ggplot2)

set.seed(1)

df <- data.frame(response = rnorm(25000, 15, 2))

ggplot(df, aes(response))  
  geom_histogram(binwidth = 0.5, color = 'black', fill = "#547fbf")  
  xlim(c(0, 24))  
  labs(x = NULL, y = NULL)  
  theme_bw(base_size = 16)

Created on 2022-11-03 with reprex v2.0.2

  • Related