added matplotlib colormaps; default changed to inferno; pyplot subplot fix

This commit is contained in:
Thomas Breloff 2016-04-13 13:49:03 -04:00
parent 82d2cc943d
commit 236a7dadc6
5 changed files with 1081 additions and 6 deletions

View File

@ -178,7 +178,7 @@ end
function addGadflyContColorScale(plt::Plot{GadflyBackend}, c)
plt.plotargs[:colorbar] == :none && return
if !isa(c, ColorGradient)
c = colorscheme(:bluesreds)
c = default_gradient()
end
push!(getGadflyContext(plt).scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(c, p))))
end

View File

@ -256,7 +256,7 @@ end
function plotly_colorscale(grad::ColorGradient, alpha = nothing)
[[grad.values[i], webcolor(grad.colors[i], alpha)] for i in 1:length(grad.colors)]
end
plotly_colorscale(c, alpha = nothing) = plotly_colorscale(ColorGradient(:bluesreds), alpha)
plotly_colorscale(c, alpha = nothing) = plotly_colorscale(default_gradient(), alpha)
const _plotly_markers = KW(
:rect => "square",

View File

@ -42,7 +42,7 @@ function getPyPlotColorMap(c::ColorGradient, α=nothing)
end
# anything else just gets a bluesred gradient
getPyPlotColorMap(c, α=nothing) = getPyPlotColorMap(ColorGradient(:bluesreds), α)
getPyPlotColorMap(c, α=nothing) = getPyPlotColorMap(default_gradient(), α)
# get the style (solid, dashed, etc)
function getPyPlotLineStyle(linetype::Symbol, linestyle::Symbol)
@ -388,7 +388,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot; kw...)
c = d[:markercolor]
if d[:zcolor] != nothing
if !isa(c, ColorGradient)
c = colorscheme(:bluesreds)
c = default_gradient()
end
extra_kwargs[:c] = convert(Vector{Float64}, d[:zcolor])
extra_kwargs[:cmap] = getPyPlotColorMap(c, d[:markeralpha])
@ -777,7 +777,8 @@ function subplot(plts::AVec{Plot{PyPlotBackend}}, layout::SubplotLayout, d::KW)
for (i,plt) in enumerate(plts)
for seriesargs in plt.seriesargs
_add_series_subplot(newplts[i]; seriesargs...)
# _add_series_subplot(newplts[i]; seriesargs...)
_add_series_subplot(newplts[i], seriesargs)
end
end

1067
src/color_gradients.jl Normal file

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ const _rainbowColors = [colorant"blue", colorant"purple", colorant"green", color
const _testColors = [colorant"darkblue", colorant"blueviolet", colorant"darkcyan",colorant"green",
darken(colorant"yellow",0.3), colorant"orange", darken(colorant"red",0.2)]
@compat const _gradients = KW(
const _gradients = KW(
:blues => [colorant"lightblue", colorant"darkblue"],
:reds => [colorant"lightpink", colorant"darkred"],
:greens => [colorant"lightgreen", colorant"darkgreen"],
@ -67,6 +67,13 @@ const _testColors = [colorant"darkblue", colorant"blueviolet", colorant"darkcya
:lighttest => map(c -> lighten(c, 0.3), _testColors),
)
function register_gradient_colors{C<:Colorant}(name::Symbol, colors::AVec{C})
_gradients[name] = colors
end
include("color_gradients.jl")
default_gradient() = ColorGradient(:inferno)
# --------------------------------------------------------------