I have made a histogram on some data, which has 3 features - race, gender, count. The histogram I plotted is like this:
But I want it to be centered for each gender, approximately like this: (random plot picture)
Here is my code
ggplot(bike_gender, aes(bikerace, Freq, fill = bikesex)) +
geom_bar(stat = 'identity') + coord_flip() + theme_tufte() +
labs(title = 'Bike crashes for people of different races and genders',
x = 'Race', y = 'Number of accidents') +
theme(plot.title = element_text(hjust = 0.5), axis.ticks = element_blank()) +
scale_fill_brewer(name = 'Gender', palette = "Dark2")
Structure:
structure(list(bikerace = structure(c(1L, 2L, 3L, 4L, 5L, 6L,
1L, 2L, 3L, 4L, 5L, 6L), .Label = c("Asian", "Other", "Native American",
"Hispanic", "Black", "White"), class = "factor"), bikesex = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Female",
"Male"), class = "factor"), Freq = c(20L, 12L, 9L, 41L, 281L,
708L, 52L, 62L, 82L, 349L, 2323L, 3377L)), class = "data.frame", row.names = c(NA,
-12L))