-1

I have data from some psychophysical experiments that I'd like to plot. My dataframe contains multiple observations from multiple participants in three paradigms of an experiment.

In other words, each participant took part in three psychophysical experiments and I'd like to plot the data on a single graph.

At present, my plot looks like this:

enter image description here

The data on the right of the plot are from one of the experiments (1), whilst the mass of data on the left are from the two other experiments (2 & 3). Essentially, I'm trying to show graphically that experiment 1 yields very different results to experiments 2 & 3.

This plot is of two parameters, 'probability_seen' and 'visual_acuity'. My dataframe also contains two other columns: subject_initials and experiment_type. As you can see, I'm separating out the subjects by colour. I'd also like to join the lines up for each of the experiments (the above plot actually contains three curves for each subject), but if I add geom_line() to my plot, I get this:

enter image description here

Obviously, I haven't asked ggplot2 to respect the state of 'experiment_type'. How do I do this?

n.b. I currently call the plot with the following code:

qplot(visual_acuity, probability_seen, data = dframe1, colour = subject_initials,
xlab = "Visual acuity", ylab = "Probability seen") + geom_line()
CaptainProg
  • 5,610
  • 23
  • 71
  • 116
  • 3
    Please provide your data (or a sample data) (using `dput` preferably) – Arun Feb 11 '13 at 18:09
  • I think what you are asking for and what you want are two different things. Using the lines that you ask for, I think the graph will be a bit too busy to clearly make your point that experiment 1 is very different. Instead, it would be better to simply highlight the points for experiment 1. If you update your question with some sample data and clarify your question, I think we can get you an answer pretty quickly. – Dinre Feb 11 '13 at 19:09
  • Contents of the dataframe are explained in the question. I simply want to sub-group the data by the only parameter not shown in the figures above, 'experiment_type'. – CaptainProg Feb 12 '13 at 11:12
  • 4
    please provide **data**, not a description of it. I think just adding `group = experiment_type` in the qplot call would do the trick, but it's hard to say anything without reproducible examples. – baptiste Feb 13 '13 at 20:51
  • Thanks baptiste; this is the correct solution. – CaptainProg Feb 14 '13 at 11:19

1 Answers1

1

As @Baptiste has stated, the solution is to add group = experiment_type to the qplot call.

CaptainProg
  • 5,610
  • 23
  • 71
  • 116