Reputation: 2059
I have a set of data here
structure(list(Variants = c(35, 1, 1, 0, 0, 0, 0, 0, 0, 0, 97,
6, 0, 0, 0, 0, 0, 0, 0, 0, 133, 6, 2, 0, 0, 0, 0, 0, 0, 0, 51499,
3508, 486, 155, 21, 2, 2, 0, 0, 0), Impact = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("HIGH", "LOW", "MODERATE",
"MODIFIER"), class = "factor"), Number.of.dogs = c(1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), class = "data.frame", row.names = c(NA,
-40L))
I am trying to make a stacked bar graph using ggplot2.
ggplot(all, aes(fill=Impact, y=Variants, x=Number.of.dogs, label = Variants)) +
geom_bar(stat="identity") +
geom_text(size = 3, position = position_stack(vjust = 0.5))
The issue is, the first bar is so large that is messing up the scale so you can't see any of the values. Here is a picture of the graph. I was wondering if there was a way to change the scale of the y axis so that you can see the values associated with each section of the bar graph?
Upvotes: 1
Views: 473
Reputation: 2716
Add
scale_y_continuous(trans='log2')
or as @Rui pointed out in the comments, since the data contains 0's the following function would be more suitable
trans=pseudo_log_trans(base = 2)
Upvotes: 4