Skip to content

Instantly share code, notes, and snippets.

@milktrader
Last active December 27, 2015 16:29
Show Gist options
  • Save milktrader/7355002 to your computer and use it in GitHub Desktop.
Save milktrader/7355002 to your computer and use it in GitHub Desktop.
Code to generate JuliaQuant logo, using official Julia colors
require(quantmod)
getSymbols("^GSPC", from = '1900-01-01')
s = yearlyReturn(GSPC)
dens = density(s)
plot(dens)
redfill = "#d66661"
redstroke = "#c93d39" #not used
greenfill = "#6bab5b"
greenstroke = "#3b972e" #not used
purplefill = "#aa7dc0"
purplestroke = "#945bb0" #not used
q1 = -0.58
q2 = -0.1
q3 = 0.25
q4 = 0.62
x1 <- min(which(dens$x >= q1))
x2 <- max(which(dens$x < q2))
x3 <- min(which(dens$x >= q3))
x4 <- max(which(dens$x < q4))
with(dens, polygon(x=c(x[c(x1,x1:x2,x2)]), y= c(0, y[x1:x2], 0), col=redfill))
with(dens, polygon(x=c(x[c(x2,x2:x3,x3)]), y= c(0, y[x2:x3], 0), col=greenfill))
with(dens, polygon(x=c(x[c(x3,x3:x4,x4)]), y= c(0, y[x3:x4], 0), col=purplefill))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment