I've run into an issue where I'm trying to create a bar chart and have the user adjust which data is visible via two variables in ylim. However some of the data I'm using has negative values, and whenever I try to use two negative values for ylim, all of my data is removed.
Here's a dummy chunk of code demonstrating the problem (where a and b would be the user-defined variables):
a <- -10
b <- -1
df2 <- data.frame(food = c("mac", "bread", "hot dog", "t-rav", "gogurt"),
rating = c(-8, -4, 2, -3, 5))
ggplot(df2, aes(food, rating)) +
geom_bar(stat = 'identity') +
ylim(a, b)
blank graph from this code:
This will do exactly what I want for two positive values, one negative and one positive, or one negative and one zero. But two negative values causes a blank graph.
Anyone know what issue I'm running into and what the fix might be?