-
-
Save kleinschmidt/7ce8cec988a84ce73ba2 to your computer and use it in GitHub Desktop.
QQ plots in Julia with Gadfly (based on Vega example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment