Problem in editing Y-Axis in ggplot

Problem: I'm trying to fix the y-axis limits and their scale in my bar chart using ggplot.

What I have Tried: Stackover flow code,s scale_y_continuous function to set limits but with this, it shows no values on the chart.
with ylim(min, max) it either shows a warning if removing specific rows it shows value in form of e for eg: 2e+05, 3e+05, and so on.

Output I want: I want the y-axis to show values in a simpler format like 20000,30000.

Code:

all_trips_v2 %>%
  mutate(weekday = wday(start_time, label = TRUE)) %>%
  group_by(usertype, day_of_week) %>%
  summarise(number_of_rides = n()
            ,average_duration = mean(ride_length)) %>%
  arrange(usertype, day_of_week) %>%
  ggplot(aes(x = day_of_week, y = number_of_rides, fill = usertype)) +
  ylim(0,500000) +
  labs(title ="Number of Ride w.r.t Usertype") +
  geom_col(position = "dodge")
all_trips_v2 %>%
  mutate(weekday = wday(start_time, label = TRUE)) %>%
  group_by(usertype, day_of_week) %>%
  summarise(number_of_rides = n()
            ,average_duration = mean(ride_length)) %>%
  arrange(usertype, day_of_week) %>%
  ggplot(aes(x = day_of_week, y = number_of_rides, fill = usertype)) +
  scale_y_continuous(name="Number of Rides", limits=c(0, 60000))
  labs(title ="Number of Ride w.r.t Usertype") +
  geom_col(position = "dodge")

Ps: It's my first time asking a question so please guide me if I did something wrong.

Hey there,
If I understand your problem correctly, one of the two should work.

library(scales)

scale_y_continous(
labels = scales::label_number(), breaks = scales::pretty_breaks(n = number of breaks you want)
  )

Or

expand_limits(x = limit you want)

See this https://scales.r-lib.org/ and Expand the plot limits, using data — expand_limits • ggplot2

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.