Skip to content

Instantly share code, notes, and snippets.

@seanhussey
Created March 20, 2013 14:55
Show Gist options
  • Save seanhussey/5205305 to your computer and use it in GitHub Desktop.
Save seanhussey/5205305 to your computer and use it in GitHub Desktop.
sj = read.csv('stocksJobs.csv')
myPalette = c('blue', 'red');
myColors = myPalette [sj$recession]
scaleFunc <- function(vec, factor=5)
factor * (vec - min(vec)) / (max(vec) - min(vec))
pointSize = scaleFunc(sj$jobClm)
plot(as.Date(sj$date), sj$sp500, main="S&P 500", xlab="Date", ylab="Closing", col=myColors, cex=pointSize) #- vector of point sizes
#- Generate legend with colors
legend('bottomright', legend=c("no", "yes"), pt.cex=2, pch=1, col=myPalette, title='Recession')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment