ggplot2 Violinplot not showing x axis lables

Hello all,

I am quite new to coding and am having trouble with a violin plot.
I would really appreciate help!

I have made a violin plot but the x axis is not showing labels all the years. (i.e. it only lables 2010, 2013, and 2016)

Does anyone know how to fix this?

Thank you heaps!!!



trump_tweets_year <- trump_tweets %>%
   mutate(year = year(trump_tweets$created_at))

ggplot(trump_tweets_year, aes(x = year, y = retweet_count,group = year))+
  geom_violin() +
  geom_jitter(alpha=0.2,size=0.5, width = 0.15)+
  labs(y= "Retweet count",
       x= "Year")

I am not sure if this elegant way or not. But this might work for you.
x = as.factor(year)

1 Like

Thank you gtmbini heaps!!!

worked great !

Rstudio helped saved the day again:)
Looking forward to when I know enough to answer questions !