gadfly color fixes; pyplot fill_between fix; pyplot hline/vline
This commit is contained in:
parent
096064ac09
commit
0e0450ced5
@ -79,12 +79,13 @@ function get_extra_theme_args(d::KW, k::Symbol)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function getGadflyLineTheme(d::KW)
|
function getGadflyLineTheme(d::KW)
|
||||||
|
lt = d[:linetype]
|
||||||
lc = convertColor(getColor(d[:linecolor]), d[:linealpha])
|
lc = convertColor(getColor(d[:linecolor]), d[:linealpha])
|
||||||
fc = convertColor(getColor(d[:fillcolor]), d[:fillalpha])
|
fc = convertColor(getColor(d[:fillcolor]), d[:fillalpha])
|
||||||
|
|
||||||
Gadfly.Theme(;
|
Gadfly.Theme(;
|
||||||
default_color = lc,
|
default_color = (lt in (:hist,:hist2d,:hexbin) ? fc : lc),
|
||||||
line_width = (d[:linetype] == :sticks ? 1 : d[:linewidth]) * Gadfly.px,
|
line_width = (lt == :sticks ? 1 : d[:linewidth]) * Gadfly.px,
|
||||||
# line_style = Gadfly.get_stroke_vector(d[:linestyle]),
|
# line_style = Gadfly.get_stroke_vector(d[:linestyle]),
|
||||||
lowlight_color = x->RGB(fc), # fill/ribbon
|
lowlight_color = x->RGB(fc), # fill/ribbon
|
||||||
lowlight_opacity = alpha(fc), # fill/ribbon
|
lowlight_opacity = alpha(fc), # fill/ribbon
|
||||||
@ -262,8 +263,8 @@ function addGadflySeries!(plt::Plot, d::KW)
|
|||||||
lt = d[:linetype]
|
lt = d[:linetype]
|
||||||
if lt == :ohlc
|
if lt == :ohlc
|
||||||
error("Haven't re-implemented after refactoring")
|
error("Haven't re-implemented after refactoring")
|
||||||
elseif lt in (:hist2d, :hexbin) && (isa(d[:linecolor], ColorGradient) || isa(d[:linecolor], ColorFunction))
|
elseif lt in (:hist2d, :hexbin) && (isa(d[:fillcolor], ColorGradient) || isa(d[:fillcolor], ColorFunction))
|
||||||
push!(gplt.scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(d[:linecolor], p))))
|
push!(gplt.scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(d[:fillcolor], p))))
|
||||||
elseif lt == :scatter && d[:markershape] == :none
|
elseif lt == :scatter && d[:markershape] == :none
|
||||||
d[:markershape] = :ellipse
|
d[:markershape] = :ellipse
|
||||||
end
|
end
|
||||||
@ -463,25 +464,24 @@ function updateGadflyPlotTheme(plt::Plot, d::KW)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if !get(d, :grid, true)
|
if !get(d, :grid, true)
|
||||||
kwargs[:grid_color] = getColor(d[:background_color])
|
kwargs[:grid_color] = getColor(d[:background_color_grid])
|
||||||
end
|
end
|
||||||
|
|
||||||
# fonts
|
# fonts
|
||||||
tfont, gfont, lfont = d[:tickfont], d[:guidefont], d[:legendfont]
|
tfont, gfont, lfont = d[:tickfont], d[:guidefont], d[:legendfont]
|
||||||
|
|
||||||
fg = getColor(d[:foreground_color])
|
|
||||||
getGadflyContext(plt).theme = Gadfly.Theme(;
|
getGadflyContext(plt).theme = Gadfly.Theme(;
|
||||||
background_color = getColor(d[:background_color]),
|
background_color = getColor(d[:background_color_inside]),
|
||||||
minor_label_color = fg,
|
minor_label_color = getColor(d[:foreground_color_text]),
|
||||||
minor_label_font = tfont.family,
|
minor_label_font = tfont.family,
|
||||||
minor_label_font_size = tfont.pointsize * Gadfly.pt,
|
minor_label_font_size = tfont.pointsize * Gadfly.pt,
|
||||||
major_label_color = fg,
|
major_label_color = gfont.color,
|
||||||
major_label_font = gfont.family,
|
major_label_font = gfont.family,
|
||||||
major_label_font_size = gfont.pointsize * Gadfly.pt,
|
major_label_font_size = gfont.pointsize * Gadfly.pt,
|
||||||
key_title_color = fg,
|
key_title_color = gfont.color,
|
||||||
key_title_font = gfont.family,
|
key_title_font = gfont.family,
|
||||||
key_title_font_size = gfont.pointsize * Gadfly.pt,
|
key_title_font_size = gfont.pointsize * Gadfly.pt,
|
||||||
key_label_color = fg,
|
key_label_color = lfont.color,
|
||||||
key_label_font = lfont.family,
|
key_label_font = lfont.family,
|
||||||
key_label_font_size = lfont.pointsize * Gadfly.pt,
|
key_label_font_size = lfont.pointsize * Gadfly.pt,
|
||||||
plot_padding = 1 * Gadfly.mm,
|
plot_padding = 1 * Gadfly.mm,
|
||||||
|
|||||||
@ -367,7 +367,6 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
extrakw = KW()
|
extrakw = KW()
|
||||||
|
|
||||||
# :shape,
|
# :shape,
|
||||||
# :hist2d, :hexbin,
|
|
||||||
# :hline, :vline, :heatmap,
|
# :hline, :vline, :heatmap,
|
||||||
# :contour, :surface, :wireframe
|
# :contour, :surface, :wireframe
|
||||||
|
|
||||||
@ -489,6 +488,18 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
needs_colorbar = true
|
needs_colorbar = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if lt in (:hline,:vline)
|
||||||
|
for yi in d[:y]
|
||||||
|
func = ax[lt == :hline ? :axhline : :axvline]
|
||||||
|
handle = func(yi;
|
||||||
|
linewidth=d[:linewidth],
|
||||||
|
color=pylinecolor(d),
|
||||||
|
linestyle=getPyPlotLineStyle(lt, d[:linestyle])
|
||||||
|
)
|
||||||
|
push!(handles, handle)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
d[:serieshandle] = handles
|
d[:serieshandle] = handles
|
||||||
|
|
||||||
# smoothing
|
# smoothing
|
||||||
@ -507,9 +518,9 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW)
|
|||||||
fillrange = d[:fillrange]
|
fillrange = d[:fillrange]
|
||||||
if fillrange != nothing && lt != :contour
|
if fillrange != nothing && lt != :contour
|
||||||
if typeof(fillrange) <: @compat(Union{Real, AVec})
|
if typeof(fillrange) <: @compat(Union{Real, AVec})
|
||||||
ax[:fill_between](d[:x], fillrange, d[:y], facecolor = fillcolor, zorder = plt.n)
|
ax[:fill_between](d[:x], fillrange, d[:y], facecolor = pyfillcolor(d), zorder = plt.n)
|
||||||
else
|
else
|
||||||
ax[:fill_between](d[:x], fillrange..., facecolor = fillcolor, zorder = plt.n)
|
ax[:fill_between](d[:x], fillrange..., facecolor = pyfillcolor(d), zorder = plt.n)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -788,12 +799,6 @@ function setxy!{X,Y}(plt::Plot{PyPlotBackend}, xy::Tuple{X,Y}, i::Integer)
|
|||||||
handle[:set_offsets](hcat(xy...))
|
handle[:set_offsets](hcat(xy...))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# series = d[:serieshandle]
|
|
||||||
# try
|
|
||||||
# series[:set_data](d[:x], d[:y])
|
|
||||||
# catch
|
|
||||||
# series[:set_offsets](hcat(d[:x], d[:y]))
|
|
||||||
# end
|
|
||||||
set_lims!(plt, d[:axis])
|
set_lims!(plt, d[:axis])
|
||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user