Skip to content

Instantly share code, notes, and snippets.

@kleinschmidt
Forked from johnmyleswhite/qqplot.jl
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kleinschmidt/7ce8cec988a84ce73ba2 to your computer and use it in GitHub Desktop.
Save kleinschmidt/7ce8cec988a84ce73ba2 to your computer and use it in GitHub Desktop.
QQ plots in Julia with Gadfly (based on Vega example)
using Stats, Distributions, Gadfly
import Gadfly.ElementOrFunction
# First add a method to the basic Gadfly.plot function for QQPair types (generated by Distributions.qqbuild())
Gadfly.plot(qq::QQPair, elements::ElementOrFunction...) = Gadfly.plot(x=qq.qx, y=qq.qy, Geom.point, Theme(highlight_width=0px), elements...)
# Now some shorthand functions
qqplot(x, y, elements::ElementOrFunction...) = Gadfly.plot(qqbuild(x, y), elements...)
qqnorm(x, elements::ElementOrFunction...) = qqplot(Normal(), x, Guide.xlabel("Theoretical Normal quantiles"), Guide.ylabel("Observed quantiles"), elements...)
x = rand(Normal(), 1000)
y = rand(Cauchy(), 1000)
plot(qqbuild(x, y))
qqplot(x, y)
qqplot(y, x)
plot(qqbuild(x, Normal()))
qqplot(x, Normal())
qqnorm(x)
qqplot(x, Normal(0, 10))
qqplot(x, Cauchy())
qqplot(Cauchy(), x)
qqplot(x, Laplace())
qqplot(Laplace(), x)
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment