diff --git a/docs/example_generation.jl b/docs/example_generation.jl index 37cdc050..c37ec04d 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -51,7 +51,10 @@ const examples = PlotExample[ PlotExample("Global", "Change the guides/background/limits/ticks. Convenience args `xaxis` and `yaxis` allow you to pass a tuple or value which will be mapped to the relevant args automatically. The `xaxis` below will be replaced with `xlabel` and `xlims` args automatically during the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!`, `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`", [ - :(plot(rand(20,3), xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), leg=false)), + :(y = rand(20,3)), + :(plot(y, xaxis=("XLABEL",(-5,30),0:2:20,:flip), background_color = RGB(0.2,0.2,0.2), leg=false)), + :(hline!(mean(y,1)+rand(1,3), line=(4,:dash,0.6,[:lightgreen :green :darkgreen]))), + :(vline!([5,10])), :(title!("TITLE")), :(yaxis!("YLABEL", :log10)) ]), diff --git a/src/backends/gadfly.jl b/src/backends/gadfly.jl index 166a7162..39abf507 100644 --- a/src/backends/gadfly.jl +++ b/src/backends/gadfly.jl @@ -63,17 +63,19 @@ end function getGadflyLineTheme(d::Dict) - lc = getColor(d[:linecolor]) - α = d[:linealpha] - if α != nothing - lc = RGBA(lc, α) - end + lc = convertColor(getColor(d[:linecolor]), d[:linealpha]) + # lc = getColor(d[:linecolor]) + # α = d[:linealpha] + # if α != nothing + # lc = RGBA(lc, α) + # end - fc = getColor(d[:fillcolor]) - α = d[:fillalpha] - if α != nothing - fc = RGBA(fc, α) - end + fc = convertColor(getColor(d[:fillcolor]), d[:fillalpha]) + # fc = getColor(d[:fillcolor]) + # α = d[:fillalpha] + # if α != nothing + # fc = RGBA(fc, α) + # end Gadfly.Theme(; @@ -104,23 +106,49 @@ function addGadflyLine!(plt::Plot, numlayers::Int, d::Dict, geoms...) push!(gfargs, Gadfly.Geom.ribbon) end - # h/vlines - if lt == :hline - kwargs[:yintercept] = d[:y] - elseif lt == :vline - kwargs[:xintercept] = d[:y] - elseif lt == :sticks - w = 0.01 * mean(diff(d[:x])) - kwargs[:xmin] = d[:x] - w - kwargs[:xmax] = d[:x] + w - elseif lt == :contour - d[:y] = reverse(d[:y]) - kwargs[:z] = d[:surface] + if lt in (:hline, :vline) + kwargs[lt == :hline ? :yintercept : :xintercept] = d[:y] + + else + if lt == :sticks + w = 0.01 * mean(diff(d[:x])) + kwargs[:xmin] = d[:x] - w + kwargs[:xmax] = d[:x] + w + elseif lt == :contour + d[:y] = reverse(d[:y]) + kwargs[:z] = d[:surface] + end + + kwargs[:x] = d[lt == :hist ? :y : :x] + kwargs[:y] = d[:y] + end + + # # h/vlines + # if lt == :hline + # kwargs[:yintercept] = d[:y] + # elseif lt == :vline + # kwargs[:xintercept] = d[:y] + # elseif lt == :sticks + # w = 0.01 * mean(diff(d[:x])) + # kwargs[:xmin] = d[:x] - w + # kwargs[:xmax] = d[:x] + w + # elseif lt == :contour + # d[:y] = reverse(d[:y]) + # kwargs[:z] = d[:surface] + # end + + # if lt == :hist + # kwargs[:x] = kwargs[:y] = d[:y] + # elseif lt != :hline && lt != :vline + # kwargs[:x] = d[:x] + # kwargs[:y] = d[:y] + # end - # add the layer - x = d[d[:linetype] == :hist ? :y : :x] - Gadfly.layer(gfargs...; x = x, y = d[:y], order=numlayers, kwargs...) + # # add the layer + # x = d[d[:linetype] == :hist ? :y : :x] + # Gadfly.layer(gfargs...; x = x, y = d[:y], order=numlayers, kwargs...) + Gadfly.layer(gfargs...; order=numlayers, kwargs...) end diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index a91effa2..67b8ec11 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -217,7 +217,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...) linecolor = color linestyle = getPyPlotLineStyle(lt, d[:linestyle]) for yi in d[:y] - func = ax[lt == :hline ? :axhline : axvline] + func = ax[lt == :hline ? :axhline : :axvline] func(yi, linewidth=d[:linewidth], color=linecolor, linestyle=linestyle) end diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index 3d77ce11..a85b4ff5 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -39,7 +39,7 @@ function rebuildUnicodePlot!(plt::Plot) # create a plot window with xlim/ylim set, but the X/Y vectors are outside the bounds width, height = iargs[:size] - o = UnicodePlots.createPlotWindow(x, y; width = width, + o = UnicodePlots.Plot(x, y; width = width, height = height, title = iargs[:title], # labels = iargs[:legend],