ggplot bar chart - y axis not starting at zero

Evening all from a wet and windy Ireland...

I am new to R and am trying to get my bar chart to start the y-axis at zero. Sounds simple but I've been banging my head against this one all afternoon!

This is my code:

Disch_data %>%
ggplot(aes(x=Month,y=Complex_Discharges))+
geom_bar(stat="identity")

Which produces this graph:

As you can see it is indeed a bar chart, but the y-axis doesn't start at zero!

How do I make it so that the y-axis starts at zero?

Thanks in advance for any help/advice :slight_smile:

1 Like

Try adding in +ylim(0,2000)
Of course, I'm sure that even a wet and windy day is beautiful in Ireland.

Hi try with this

Disch_data %>%
ggplot(aes(x=Month,y=Complex_Discharges))+
geom_bar(stat="identity") +
scale_y_continuous(expand = c(0, 0), limits = c(0, 2000)) # For start in 0.0

Comes up with error:
Error: Discrete value supplied to continuous scale

comes up with error:
Error: Discrete value supplied to continuous scale

Comes up with error:
Error: Discrete value supplied to continuous scale

The values used for your y axis are not numbers but text. Run

Disch_data$Complex_Discharges <- as.numeric(Disch_data$Complex_Discharges)

and see how the graph changes. Other adjustments may be needed depending on how they got to be text.
You can tell they are not numbers by the wildly different increments between tick marks.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.