palettes notebook

This commit is contained in:
Thomas Breloff 2015-10-20 12:55:36 -04:00
parent 4ef2fb9933
commit d1e9cc5800
3 changed files with 1684 additions and 209 deletions

File diff suppressed because one or more lines are too long

View File

@ -648,12 +648,12 @@ end
getGadflyWriteFunc(::MIME"image/png") = Gadfly.PNG getGadflyWriteFunc(::MIME"image/png") = Gadfly.PNG
getGadflyWriteFunc(::MIME"image/svg+xml") = Gadfly.SVG getGadflyWriteFunc(::MIME"image/svg+xml") = Gadfly.SVG
getGadflyWriteFunc(::MIME"text/html") = Gadfly.SVGJS # getGadflyWriteFunc(::MIME"text/html") = Gadfly.SVGJS
getGadflyWriteFunc(::MIME"application/pdf") = Gadfly.PDF getGadflyWriteFunc(::MIME"application/pdf") = Gadfly.PDF
getGadflyWriteFunc(::MIME"application/postscript") = Gadfly.PS getGadflyWriteFunc(::MIME"application/postscript") = Gadfly.PS
getGadflyWriteFunc(m::MIME) = error("Unsupported in Gadfly/Immerse: ", m) getGadflyWriteFunc(m::MIME) = error("Unsupported in Gadfly/Immerse: ", m)
for mime in (MIME"image/png", MIME"image/svg+xml", MIME"text/html", MIME"application/pdf", MIME"application/postscript") for mime in (MIME"image/png", MIME"image/svg+xml", MIME"application/pdf", MIME"application/postscript")
@eval function Base.writemime{P<:GadflyOrImmerse}(io::IO, ::$mime, plt::PlottingObject{P}) @eval function Base.writemime{P<:GadflyOrImmerse}(io::IO, ::$mime, plt::PlottingObject{P})
func = getGadflyWriteFunc($mime()) func = getGadflyWriteFunc($mime())
dowritemime(io, func, plt) dowritemime(io, func, plt)

View File

@ -311,7 +311,7 @@ function getPaletteUsingGradientSymbol(palette, bgcolor::Colorant, numcolors::In
else else
grad = ColorGradient(palette) grad = ColorGradient(palette)
end end
zrng = getpctrange(numcolors) zrng = get_zvalues(numcolors)
RGBA[getColorZ(grad, z) for z in zrng] RGBA[getColorZ(grad, z) for z in zrng]
end end
@ -338,6 +338,16 @@ function getpctrange(n::Int)
zs zs
end end
function get_zvalues(n::Int)
offsets = getpctrange(ceil(Int,n/4)+1)/4
offsets = vcat(offsets[1], offsets[3:end])
zvalues = Float64[]
for offset in offsets
append!(zvalues, offset + [0.0, 0.5, 0.25, 0.75])
end
vcat(zvalues[1], 1.0, zvalues[2:n-1])
end
# ---------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------
# TODO: try to use the algorithms from https://github.com/timothyrenner/ColorBrewer.jl # TODO: try to use the algorithms from https://github.com/timothyrenner/ColorBrewer.jl