I've just conducted a simple validation experiment whereby participants rated the pleasantness of photos of different scenes.
I'm currently building a bar chart in ggplot which has a pleasantness rating as the y variable, and the specific scene type (e.g. park, beach, rubbish tip, derelict building, etc) as the x variable. However, I've also categorised each sceneType as either "positive" or "negative" within the variable sceneValence. Both of these variables are in my sceneTable.
So far, I've managed to produce a relatively decent bar graph which presents all of the different sceneTypes along the x-axis, and colours them according to their sceneValence. See the code below:
sceneGraph <- ggplot(sceneTable, aes(y = Response, x = sceneType, fill = sceneValence)) +
geom_bar(stat = "identity", position = "dodge", width = 0.6, alpha = 0.6)
+ geom_errorbar(aes(ymin = Response-se, ymax = Response+se), position = position_dodge(width=0.6),
width = .1, size = 0.5) + labs(title = "Pleasantness Rating by Scene Type",
x = "Scene Type", y = "Pleasantness Rating", fill = "Scene Valence")
However, what I would really love to do is to reorder the bars in the graph so that all of the "negative" sceneTypes are on one side of the x-axis (in one colour), and all of the "positive" sceneTypes are on the other side of the x-axis (in a different colour).
At the moment, all of my sceneTypes are completely intermixed along the x-axis (in alphabetical order), irrespective of their valence, and can only be distinguished based upon their colour. I would also like to separate sceneType according to sceneValence, which allows for easier within-valence comparison. Is this possible?