From OpenWetWare

Revision as of 18:58, 10 March 2011 by Alex O. Holcombe (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search


Alex Holcombe
Sarah McIntyre
Fahed Jbarah
• Shih-Yu Lo
• Patrick Goodbourn
Lizzy Nguyen


Skills Checklist
Python Programming
Psychopy/VisionEgg Installation Notes
R analysis,plot,stats
Buttonbox with photocell
Programming Cheat Sheets

Good advice on graph choice, from human perceptual standpoint by Frank Harrell


In the lab we usually use the R package, ggplot2, for graphs. Ask Sarah about the ggplot2 book.

For custom colour schemes, the Chart of R Colors is a helpful resource. The table with named colours is most useful.

ggplot2 tips:

#where 'g' is your ggplot object
str(g)  #gives you everything!
summary(g) #gives a summary
last_plot() #refreshes the last plot and returns the struct
p=p+scale_y_continuous(breaks=c(0,0.5,1),minor_breaks=c(.25,.75)) #changing axis breaks
p=p+opts(title="one-behind errors")
p=p+xlab('relative phase')
opts(panel.grid.minor = theme_blank())+
last_plot() + opts(panel.grid.minor = theme_line(colour = "black") )
facet_grid(.~subject)  # rows~columns
g<-g+stat_summary(fun.y=mean,geom="point",position="jitter") #getting jitter to work when you're collapsing across other variables with stat_summary
g=g+ stat_smooth(method="glm",family="binomial",fullrange=TRUE) #adds logistic smoother to plot
#it's impossible to extract the function fits however because they're fit on the fly
#how can I fit an arbitrary function, like a psychometric function, e.g. cumulative gaussian with chance rate and lapse rate? Logistic is restricted to 0->1

order used for scale mapping (color, etc.) is perhaps the order of the levels property of the vector. This gives bizarre results because R's sort(unique(x)) default does not alphabetize strings. Getting things to appear in a graph or something the way you want may require reordering the 'levels' of a factor, like this to put DL as the last subject to be graphed:

pvalsCIs$subject<-factor(pvalsCIs$subject,levels=c("AH","SM","SYL","WYC","DL")) #levels(pvalsCIs$subject)
Personal tools