jwdink / eyetrackingR

This package is designed to make dealing with eye-tracking data easier. It addresses tasks along the pipeline from raw data to analysis and visualization.
http://eyetrackingr.com
Other
82 stars 20 forks source link

Multiple lines in plot when visualizing time course #53

Closed tessvdz closed 6 years ago

tessvdz commented 7 years ago

Hello,

I have a question regarding plotting the lines of multiple AoI's in one plot when visualizing the time course. I tried so many options already but I still get the same outcome in most cases. Four separate plots, one per AOI (for me being: AOI1, AOI2, AOI3, AOI4 with binary data), rather than one plot with the four lines with different colors in one plot. But I also have one column AOI consisting of numbers 1 to 4 in which 1 equals AOI1, 2 equals AOI2, and so forth. In your example of the growth curve analysis, both the fixations to the Animate and Inanimate AOI are included in one plot.

See the uploaded image for the outcome I get when I tried to plot my data with codes as:

response_time2 <- make_time_sequence_data(response_window_clean, time_bin_size = 50, predictor_columns =c("AOI"), aois =c("AOI1", "AOI2", "AOI3", "AOI4"))

plot(response_time2, predictor_column = "AOI" ) + theme_light() + coord_cartesian(ylim = c(0,1))

Also when I tried to get rid of the predictor columns I got the same result.

schermafbeelding 2017-04-01 om 13 51 21

I followed the instructions given by the eyetrackingR package, such as:

eyesdata <- make_eyetrackingr_data(data, participant_column = "SUBJECT", trial_column = "TRIAL", item_column = "ITEM", time_column = "TIMESTAMP", trackloss_column = "TRACKLOSS", aoi_columns = c('AOI1', 'AOI2','AOI3','AOI4'), treat_non_aoi_looks_as_missing = TRUE)

response_window_clean <- clean_by_trackloss(data = eyesdata, trial_prop_thresh = .25)

It would be great if you could help me with this issue. I am already struggling with it for a while, and so far now one around me was able to help solving this problem with me.

Let me know if you need anything more

brockf commented 7 years ago

Hi @tessvdz -

The plot() function in eyetrackingR is meant to be a way to take a quick look at your data during analysis. If you would like to generate specific kinds of visualizations (e.g., for publication), I suggest you use ggplot2() to plot the dataframes generated by eyetrackingR (e.g., response_time2, response_window_clean).

tessvdz commented 7 years ago

Hi brockf,

Thanks for your response!

But if I will use the ggplot() function for the dataframe response_time2 what variable should I use to get the proportions to the four AOIs over time. Because the Prop variable only gives 0's and 1's.. Thereby, the AOI column in the response_time2 is generated into a variable with only character, consisting of 'AOI1', 'AOI2, etc. So only one straight line appears when I plot that as the colour= or group= in the plot.

In my general response_window_clean there is no separate column with the proportion of fixations to the four AOIs.

Thanks a lot

brockf commented 7 years ago

Hi @tessvdz

response_time2 shows participant-level AOI data over time. The plot you want will aggregate over participants, turning those 0's and 1's into a proportion.

In ggplot2, the easiest way to do this is to use the stat_summary(fun.y='mean', geom='line') function.

jwdink commented 7 years ago

You might also want to look into stat_summary_bin.

tessvdz commented 7 years ago

Do you mean: http://www.eyetracking-r.com/docs/summary.bin_analysis?

jwdink commented 7 years ago

Nope. @brockf suggested ggplot2's stat_summary, I was mentioning that stat_summary_bin is sometimes more helpful for eye-tracking data.