How can I stop ggplot2 stacking value when using geom_col() ?

I used this code to create a plot:


ggplot(avg_monthly_2020) + 
  geom_col(aes(x=month,y=mean_time,fill = customer_type)) + 
  scale_x_discrete(limit=c("1","2","3","4","5","6","7","8","9","10","11","12"),
                   labels=c("Jan","Feb","Mar","Apr","May","June","July","Aug","Sep","Oct","Nov","Dec"))+
  scale_y_continuous(limit=c(0.0,180.0),breaks = c(0,20,40,60,80,100,120,140,160,180))+
  labs(title="Average Traveling Time Per Month",
       subtitle = "Record of average traveling time by 2 groups of customer each month",
       caption = "Data collected by Cyclistic from January 2020 to December 2020",
       y = "Average Time (Minutes)",x= "Month") +
  theme(title=title_style,
        plot.subtitle = subtitle_style,
        plot.caption = caption_style,
        legend.position = "top",
        legend.title = element_blank(),
        axis.title=axis_style)

It produced this plot :

How do separate "customer" and "member" into 2 columns for the same month?

Thank you

FAQ: Barplots • ggplot2 (tidyverse.org)

2 Likes

This topic was automatically closed 7 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.