0

I am using qplot to summarize a dataset and generate a plot for 2 ACL injured athletes that shows the mean EMG and 95% confidence interval band for different phases of a continuous jumping movement. Each athlete performed 20 jumps so this provides a summary of all 20 jumps for each athlete.

Is there a straightforward method in qplot to generate a figure that shows only the mean value and the confidence band (i.e. that removes the individual data points)? I think this is a cleaner way of showing my data but I'm struggling with a way to do this beyond manipulating the transparency using geom_point.

The code I am using is:

plot + stat_sum_df("mean_cl_normal", geom = "smooth")+
stat_summary(fun.y=mean, fun.ymin=mean, fun.ymax=mean, geom="point", size=3,fill="white",pch=21) 

Mean EMG +/- 95% CI band

Matt Jordan
  • 567
  • 1
  • 5
  • 14

2 Answers2

0

This isn't likely the correct way of doing this as I'm sure there is a function that can make this happen, but formatting geom_point as:

+geom_point(fill="white", colour="white", pch=21)

and ensuring this layer comes before the stat_smooth layers will render the points invisible providing the panel background is set to be filled with white.

If there is another option in ggplot2 then please let me know. Otherwise, while this is limited, it works and generates the following plot.

EMG Smooth Plot no Data Points

Matt Jordan
  • 567
  • 1
  • 5
  • 14
0

Do you really need to call geom_point() at all? If I understand what you're asking correctly, the only layer you want in your plot is from stat_summary. If so, you don't need geom_point.

Does this do what you want? (I wasn't sure what your real data was so I just used mtcars as an example.)

ggplot(data=mtcars, aes(x=cyl, y=mpg)) +
 stat_summary(fun.y=mean, geom='point', fill='white', size=4, shape=21) + 
 stat_summary(fun.data=mean_cl_normal, geom='smooth', se=T, color='black')

Plot without any raw data

In contrast, if you wanted raw data on the plot, you could do

ggplot(data=mtcars, aes(x=cyl, y=mpg)) + 
 geom_point(color='red') +
 stat_summary(fun.y=mean, geom='point', fill='white', size=4, shape=21) + 
 stat_summary(fun.data=mean_cl_normal, geom='smooth', se=T, color='black')

I'm not 100% sure why calling stat_summary() twice is required, instead of doing geom=c('point', 'smooth') insider a single stat_summary() call. Maybe that compound geom trick only works in qplot().

Curt F.
  • 4,690
  • 2
  • 22
  • 39