working on corrplot and recipes
This commit is contained in:
parent
a51a8abf27
commit
15a4b50ce4
File diff suppressed because one or more lines are too long
10
src/Plots.jl
10
src/Plots.jl
@ -72,9 +72,6 @@ export
|
||||
getColor,
|
||||
getColorZ,
|
||||
|
||||
PlotRecipe,
|
||||
EllipseRecipe,
|
||||
|
||||
debugplots,
|
||||
|
||||
supportedArgs,
|
||||
@ -82,7 +79,12 @@ export
|
||||
supportedTypes,
|
||||
supportedStyles,
|
||||
supportedMarkers,
|
||||
subplotSupported
|
||||
subplotSupported,
|
||||
|
||||
# recipes
|
||||
PlotRecipe,
|
||||
EllipseRecipe,
|
||||
corrplot
|
||||
|
||||
# ---------------------------------------------------------
|
||||
|
||||
|
||||
@ -85,7 +85,10 @@ function createGadflyPlotObject(d::Dict)
|
||||
unshift!(gplt.guides, Gadfly.Guide.manual_color_key("", @compat(AbstractString)[], Color[]))
|
||||
end
|
||||
|
||||
gplt.theme = Gadfly.Theme(background_color = getColor(d[:background_color]))
|
||||
gplt.theme = Gadfly.Theme(
|
||||
background_color = getColor(d[:background_color]),
|
||||
plot_padding = 1 * Gadfly.mm,
|
||||
)
|
||||
gplt
|
||||
end
|
||||
|
||||
@ -493,7 +496,7 @@ function linkXAxis(subplt::Subplot{GadflyPackage})
|
||||
for (i,(r,c)) in enumerate(subplt.layout)
|
||||
gplt = subplt.plts[i].o
|
||||
if r < nrows(subplt.layout)
|
||||
#addOrReplace(gplt.guides, Gadfly.Guide.xticks; label=false)
|
||||
addOrReplace(gplt.guides, Gadfly.Guide.xticks; label=false)
|
||||
addOrReplace(gplt.guides, Gadfly.Guide.xlabel, "")
|
||||
end
|
||||
end
|
||||
@ -516,7 +519,7 @@ function linkYAxis(subplt::Subplot{GadflyPackage})
|
||||
for (i,(r,c)) in enumerate(subplt.layout)
|
||||
gplt = subplt.plts[i].o
|
||||
if c > 1
|
||||
#addOrReplace(gplt.guides, Gadfly.Guide.yticks; label=false)
|
||||
addOrReplace(gplt.guides, Gadfly.Guide.yticks; label=false)
|
||||
addOrReplace(gplt.guides, Gadfly.Guide.ylabel, "")
|
||||
end
|
||||
end
|
||||
|
||||
@ -54,3 +54,39 @@ function getRecipeArgs(ep::EllipseRecipe)
|
||||
[(:line, (3, [:dot :solid], [:red :blue], :path))]
|
||||
end
|
||||
|
||||
# -------------------------------------------------
|
||||
|
||||
|
||||
"Do a correlation plot"
|
||||
function corrplot{T<:Real,S<:Real}(mat::AMat{T}, corrmat::AMat{S};
|
||||
colors = :redsblues)
|
||||
m = size(mat,2)
|
||||
|
||||
# might be a mistake?
|
||||
@assert m <= 10
|
||||
@assert size(corrmat) == (m,m)
|
||||
|
||||
# create a subplot grid, and a gradient from -1 to 1
|
||||
p = subplot(zeros(1,m^2), n=m^2, link=true)
|
||||
cgrad = ColorGradient(:redsblues,[-1,1])
|
||||
|
||||
# make all the plots
|
||||
for i in 1:m
|
||||
for j in 1:m
|
||||
idx = p.layout[i,j]
|
||||
if i==j
|
||||
# histogram on diagonal
|
||||
plt = histogram(mat[:,i], c=:black)
|
||||
else
|
||||
# scatter plots off-diagonal, color determined by correlation
|
||||
plt = scatter(mat[:,j], mat[:,i], ms=4, c=getColorZ(cgrad, corrmat[i,j]))
|
||||
end
|
||||
# replace the plt
|
||||
p.plts[idx] = plt
|
||||
end
|
||||
end
|
||||
|
||||
# link the axes
|
||||
subplot!(p, link=true)
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user