0

I have ggplot with mean of imdb movie rating per year plotted and I wanted to plot ribbon like layer to it, that shows the standard error for each point but is obviously continues ( if that's possible even)

  ggplot(data = avg_imdb_movie_year, aes( x = startYear, y = avg_rating)) +
    geom_point() +
    geom_ribbon(aes(x = start_Year, y = standard_error, xmin = min(xx), xmax = max(xx)))

The xx is sequence corresponding to the years of the movies. The standard_error is simply calculated as sd(average_rating) [that is the difference to mean for each data point]

I think I do something completely wrong. If my data is discrete is there a way I can draw ribbon like standard error around the mean points?

Additional to that I have a question about adding layers that have different data frame. Here is example, I want to add to this ggplot another geom_point() layer where the data would be awarded movie ratings average per year. But I run into error:

 ggplot(data = avg_imdb_movie_year, aes( x = startYear, y = avg_rating)) +
    geom_point() +
    geom_point(aes(x = avg_awarded_moves_year$year_film, 
                   y = avg_awarded_moves_year$average_per_year))

Error message: Error: Aesthetics must be either length 1 or the same as the data (138): x and y

I realise that it's because there are less years (rows) in awarded_movies table, but I don't know how to add another plot from different dataset to existing ggplot. Do anyone has any ideas?

user
  • 241
  • 1
  • 9
  • 1
    Welcome to SO ! Can you provide a small reproducible example of your dataset (see this link: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – dc37 Apr 22 '20 at 17:12
  • Have you tried not setting the aesthetics in the ggplot() call? Try them in the geom_point() functions instead :) – mlcyo Apr 22 '20 at 22:40

0 Answers0