Why values in bar graph in Y axis is shown as 5e+07 format

values format in Y axis is differ from its format in the data set, and also a part of my code in shown in x axis as shown in the picture

> budget_genres <- cleaned_movie_col %>% 
  group_by(genre_1) %>%
  summarise(avg_genre_budget=mean(budget), avg_genre_revenue=mean(box_office_revenue)) %>% 
  arrange(avg_genre_budget)
ggplot(data = budget_genres)+geom_bar(mapping =  aes(x=reorder(genre_1,avg_genre_budget, Fun=mean), y=avg_genre_budget, fill=-avg_genre_budget), stat = "identity", Fun=mean)

You could try disabling scientific notation, but I think a better thing to try the scale_y_continuous() function, and using the labels=comma argument from the scales library.

First import the scales library (on top of ggplot2) :

library(scales)

^install if needed

For clarity, let's say you save your current ggplot to the variable plot:

# your current plot
plot <- ggplot(data = budget_genres) + geom_bar(mapping =  aes(x=reorder(genre_1,avg_genre_budget, Fun=mean), y=avg_genre_budget, fill=-avg_genre_budget), stat = "identity", Fun=mean)

You could try adding the scale_y_continuous() function to the plot like so:

# the incremental change to the y axis
plot + scale_y_continuous(labels = comma)

Not 100% sure this will fix the issue but I think it probably would.

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.