diff --git a/src/Plots.jl b/src/Plots.jl index a90df6d7..899de166 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -186,52 +186,52 @@ include("output.jl") # --------------------------------------------------------- -scatter(args...; kw...) = plot(args...; kw..., linetype = :scatter) -scatter!(args...; kw...) = plot!(args...; kw..., linetype = :scatter) -bar(args...; kw...) = plot(args...; kw..., linetype = :bar) -bar!(args...; kw...) = plot!(args...; kw..., linetype = :bar) -barh(args...; kw...) = plot(args...; kw..., linetype = :barh, orientation = :h) -barh!(args...; kw...) = plot!(args...; kw..., linetype = :barh, orientation = :h) -histogram(args...; kw...) = plot(args...; kw..., linetype = :hist) -histogram!(args...; kw...) = plot!(args...; kw..., linetype = :hist) -histogram2d(args...; kw...) = plot(args...; kw..., linetype = :hist2d) -histogram2d!(args...; kw...) = plot!(args...; kw..., linetype = :hist2d) -density(args...; kw...) = plot(args...; kw..., linetype = :density) -density!(args...; kw...) = plot!(args...; kw..., linetype = :density) -heatmap(args...; kw...) = plot(args...; kw..., linetype = :heatmap) -heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap) -hexbin(args...; kw...) = plot(args...; kw..., linetype = :hexbin) -hexbin!(args...; kw...) = plot!(args...; kw..., linetype = :hexbin) -sticks(args...; kw...) = plot(args...; kw..., linetype = :sticks, marker = :ellipse) -sticks!(args...; kw...) = plot!(args...; kw..., linetype = :sticks, marker = :ellipse) -hline(args...; kw...) = plot(args...; kw..., linetype = :hline) -hline!(args...; kw...) = plot!(args...; kw..., linetype = :hline) -vline(args...; kw...) = plot(args...; kw..., linetype = :vline) -vline!(args...; kw...) = plot!(args...; kw..., linetype = :vline) -ohlc(args...; kw...) = plot(args...; kw..., linetype = :ohlc) -ohlc!(args...; kw...) = plot!(args...; kw..., linetype = :ohlc) -pie(args...; kw...) = plot(args...; kw..., linetype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) -pie!(args...; kw...) = plot!(args...; kw..., linetype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) -contour(args...; kw...) = plot(args...; kw..., linetype = :contour) -contour!(args...; kw...) = plot!(args...; kw..., linetype = :contour) -contour3d(args...; kw...) = plot(args...; kw..., linetype = :contour3d) -contour3d!(args...; kw...) = plot!(args...; kw..., linetype = :contour3d) -surface(args...; kw...) = plot(args...; kw..., linetype = :surface) -surface!(args...; kw...) = plot!(args...; kw..., linetype = :surface) -wireframe(args...; kw...) = plot(args...; kw..., linetype = :wireframe) -wireframe!(args...; kw...) = plot!(args...; kw..., linetype = :wireframe) -path3d(args...; kw...) = plot(args...; kw..., linetype = :path3d) -path3d!(args...; kw...) = plot!(args...; kw..., linetype = :path3d) -plot3d(args...; kw...) = plot(args...; kw..., linetype = :path3d) -plot3d!(args...; kw...) = plot!(args...; kw..., linetype = :path3d) -scatter3d(args...; kw...) = plot(args...; kw..., linetype = :scatter3d) -scatter3d!(args...; kw...) = plot!(args...; kw..., linetype = :scatter3d) -boxplot(args...; kw...) = plot(args...; kw..., linetype = :boxplot) -boxplot!(args...; kw...) = plot!(args...; kw..., linetype = :boxplot) -violin(args...; kw...) = plot(args...; kw..., linetype = :violin) -violin!(args...; kw...) = plot!(args...; kw..., linetype = :violin) -quiver(args...; kw...) = plot(args...; kw..., linetype = :quiver) -quiver!(args...; kw...) = plot!(args...; kw..., linetype = :quiver) +scatter(args...; kw...) = plot(args...; kw..., seriestype = :scatter) +scatter!(args...; kw...) = plot!(args...; kw..., seriestype = :scatter) +bar(args...; kw...) = plot(args...; kw..., seriestype = :bar) +bar!(args...; kw...) = plot!(args...; kw..., seriestype = :bar) +barh(args...; kw...) = plot(args...; kw..., seriestype = :barh, orientation = :h) +barh!(args...; kw...) = plot!(args...; kw..., seriestype = :barh, orientation = :h) +histogram(args...; kw...) = plot(args...; kw..., seriestype = :hist) +histogram!(args...; kw...) = plot!(args...; kw..., seriestype = :hist) +histogram2d(args...; kw...) = plot(args...; kw..., seriestype = :hist2d) +histogram2d!(args...; kw...) = plot!(args...; kw..., seriestype = :hist2d) +density(args...; kw...) = plot(args...; kw..., seriestype = :density) +density!(args...; kw...) = plot!(args...; kw..., seriestype = :density) +heatmap(args...; kw...) = plot(args...; kw..., seriestype = :heatmap) +heatmap!(args...; kw...) = plot!(args...; kw..., seriestype = :heatmap) +hexbin(args...; kw...) = plot(args...; kw..., seriestype = :hexbin) +hexbin!(args...; kw...) = plot!(args...; kw..., seriestype = :hexbin) +sticks(args...; kw...) = plot(args...; kw..., seriestype = :sticks, marker = :ellipse) +sticks!(args...; kw...) = plot!(args...; kw..., seriestype = :sticks, marker = :ellipse) +hline(args...; kw...) = plot(args...; kw..., seriestype = :hline) +hline!(args...; kw...) = plot!(args...; kw..., seriestype = :hline) +vline(args...; kw...) = plot(args...; kw..., seriestype = :vline) +vline!(args...; kw...) = plot!(args...; kw..., seriestype = :vline) +ohlc(args...; kw...) = plot(args...; kw..., seriestype = :ohlc) +ohlc!(args...; kw...) = plot!(args...; kw..., seriestype = :ohlc) +pie(args...; kw...) = plot(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) +pie!(args...; kw...) = plot!(args...; kw..., seriestype = :pie, aspect_ratio = :equal, grid=false, xticks=nothing, yticks=nothing) +contour(args...; kw...) = plot(args...; kw..., seriestype = :contour) +contour!(args...; kw...) = plot!(args...; kw..., seriestype = :contour) +contour3d(args...; kw...) = plot(args...; kw..., seriestype = :contour3d) +contour3d!(args...; kw...) = plot!(args...; kw..., seriestype = :contour3d) +surface(args...; kw...) = plot(args...; kw..., seriestype = :surface) +surface!(args...; kw...) = plot!(args...; kw..., seriestype = :surface) +wireframe(args...; kw...) = plot(args...; kw..., seriestype = :wireframe) +wireframe!(args...; kw...) = plot!(args...; kw..., seriestype = :wireframe) +path3d(args...; kw...) = plot(args...; kw..., seriestype = :path3d) +path3d!(args...; kw...) = plot!(args...; kw..., seriestype = :path3d) +plot3d(args...; kw...) = plot(args...; kw..., seriestype = :path3d) +plot3d!(args...; kw...) = plot!(args...; kw..., seriestype = :path3d) +scatter3d(args...; kw...) = plot(args...; kw..., seriestype = :scatter3d) +scatter3d!(args...; kw...) = plot!(args...; kw..., seriestype = :scatter3d) +boxplot(args...; kw...) = plot(args...; kw..., seriestype = :boxplot) +boxplot!(args...; kw...) = plot!(args...; kw..., seriestype = :boxplot) +violin(args...; kw...) = plot(args...; kw..., seriestype = :violin) +violin!(args...; kw...) = plot!(args...; kw..., seriestype = :violin) +quiver(args...; kw...) = plot(args...; kw..., seriestype = :quiver) +quiver!(args...; kw...) = plot!(args...; kw..., seriestype = :quiver) title!(s::AbstractString; kw...) = plot!(; title = s, kw...) diff --git a/src/args.jl b/src/args.jl index bf248db8..b84edd94 100644 --- a/src/args.jl +++ b/src/args.jl @@ -46,12 +46,12 @@ const _allTypes = vcat([ :imagesc => :image, ) -like_histogram(linetype::Symbol) = linetype in (:hist, :density) -like_line(linetype::Symbol) = linetype in (:line, :path, :steppre, :steppost) -like_surface(linetype::Symbol) = linetype in (:contour, :contour3d, :heatmap, :surface, :wireframe, :image) +like_histogram(seriestype::Symbol) = seriestype in (:hist, :density) +like_line(seriestype::Symbol) = seriestype in (:line, :path, :steppre, :steppost) +like_surface(seriestype::Symbol) = seriestype in (:contour, :contour3d, :heatmap, :surface, :wireframe, :image) -is3d(linetype::Symbol) = linetype in _3dTypes -is3d(d::KW) = trueOrAllTrue(is3d, d[:linetype]) +is3d(seriestype::Symbol) = seriestype in _3dTypes +is3d(d::KW) = trueOrAllTrue(is3d, d[:seriestype]) const _allStyles = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] @compat const _styleAliases = KW( @@ -120,7 +120,7 @@ _seriesDefaults[:axis] = :left _seriesDefaults[:label] = "AUTO" _seriesDefaults[:seriescolor] = :auto _seriesDefaults[:seriesalpha] = nothing -_seriesDefaults[:linetype] = :path +_seriesDefaults[:seriestype] = :path _seriesDefaults[:linestyle] = :solid _seriesDefaults[:linewidth] = :auto _seriesDefaults[:linecolor] = :match @@ -300,10 +300,11 @@ add_aliases(:makeralpha, :ma, :malpha, :mα, :makeropacity, :mopacity) add_aliases(:markerstrokealpha, :msa, :msalpha, :msα, :markerstrokeopacity, :msopacity) add_aliases(:fillalpha, :fa, :falpha, :fα, :fillopacity, :fopacity) +# series attributes +add_aliases(:seriestype, :st, :t, :typ, :linetype, :lt) add_aliases(:label, :lab) add_aliases(:line, :l) add_aliases(:linewidth, :w, :width, :lw) -add_aliases(:linetype, :lt, :t, :seriestype) add_aliases(:linestyle, :style, :s, :ls) add_aliases(:marker, :m, :mark) add_aliases(:markershape, :shape) @@ -451,9 +452,9 @@ end function processLineArg(d::KW, arg) - # linetype + # seriestype if allLineTypes(arg) - d[:linetype] = arg + d[:seriestype] = arg # linestyle elseif allStyles(arg) @@ -587,8 +588,8 @@ function preprocessArgs!(d::KW) processLineArg(d, arg) end - if haskey(d, :linetype) && haskey(_typeAliases, d[:linetype]) - d[:linetype] = _typeAliases[d[:linetype]] + if haskey(d, :seriestype) && haskey(_typeAliases, d[:seriestype]) + d[:seriestype] = _typeAliases[d[:seriestype]] end # handle marker args... default to ellipse if shape not set @@ -732,9 +733,9 @@ _markershape_supported(pkg::AbstractBackend, shapes::AVec) = all([_markershape_s function warnOnUnsupported(pkg::AbstractBackend, d::KW) (d[:axis] in supportedAxes(pkg) || warn("axis $(d[:axis]) is unsupported with $pkg. Choose from: $(supportedAxes(pkg))")) - (d[:linetype] == :none - || d[:linetype] in supportedTypes(pkg) - || warn("linetype $(d[:linetype]) is unsupported with $pkg. Choose from: $(supportedTypes(pkg))")) + (d[:seriestype] == :none + || d[:seriestype] in supportedTypes(pkg) + || warn("seriestype $(d[:seriestype]) is unsupported with $pkg. Choose from: $(supportedTypes(pkg))")) (d[:linestyle] in supportedStyles(pkg) || warn("linestyle $(d[:linestyle]) is unsupported with $pkg. Choose from: $(supportedStyles(pkg))")) (d[:markershape] == :none @@ -826,8 +827,8 @@ function getPlotArgs(pkg::AbstractBackend, kw, idx::Int; set_defaults = true) d end -function has_black_border_for_default(lt::Symbol) - like_histogram(lt) || lt in (:hexbin, :bar) +function has_black_border_for_default(st::Symbol) + like_histogram(st) || st in (:hexbin, :bar) end # # # build the argument dictionary for a series @@ -847,8 +848,8 @@ end # end # end # -# if haskey(_typeAliases, d[:linetype]) -# d[:linetype] = _typeAliases[d[:linetype]] +# if haskey(_typeAliases, d[:seriestype]) +# d[:seriestype] = _typeAliases[d[:seriestype]] # end # # aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex) @@ -876,7 +877,7 @@ end # # update colors # for csym in (:linecolor, :markercolor, :fillcolor) # d[csym] = if d[csym] == :match -# if has_black_border_for_default(d[:linetype]) && csym == :linecolor +# if has_black_border_for_default(d[:seriestype]) && csym == :linecolor # :black # else # d[:seriescolor] @@ -899,7 +900,7 @@ end # end # # # scatter plots don't have a line, but must have a shape -# if d[:linetype] in (:scatter, :scatter3d) +# if d[:seriestype] in (:scatter, :scatter3d) # d[:linewidth] = 0 # if d[:markershape] == :none # d[:markershape] = :ellipse diff --git a/src/backends.jl b/src/backends.jl index 70c4ce1b..ae0530b2 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -52,6 +52,9 @@ _update_plot_pos_size{P<:AbstractBackend}(plt::AbstractPlot{P}, d::KW) = nothing subplot(pkg::AbstractBackend; kw...) = error("subplot($pkg; kw...) is not implemented") subplot!(pkg::AbstractBackend, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented") +# don't do anything as a default +_before_add_series(plt::Plot) = nothing + # --------------------------------------------------------- diff --git a/src/backends/bokeh.jl b/src/backends/bokeh.jl index 92fbce1d..39048d3b 100644 --- a/src/backends/bokeh.jl +++ b/src/backends/bokeh.jl @@ -18,7 +18,7 @@ supportedArgs(::BokehBackend) = [ # :legend, :seriescolor, :seriesalpha, :linestyle, - :linetype, + :seriestype, :linewidth, # :linealpha, :markershape, @@ -104,14 +104,14 @@ const _glyphtypes = KW( function bokeh_glyph_type(d::KW) - lt = d[:linetype] + st = d[:seriestype] mt = d[:markershape] - if lt == :scatter && mt == :none + if st == :scatter && mt == :none mt = :ellipse end # if we have a marker, use that - if lt == :scatter || mt != :none + if st == :scatter || mt != :none return _glyphtypes[mt] end diff --git a/src/backends/gadfly.jl b/src/backends/gadfly.jl index 11db8afc..8f7756e8 100644 --- a/src/backends/gadfly.jl +++ b/src/backends/gadfly.jl @@ -5,7 +5,7 @@ supportedArgs(::GadflyBackend) = [ :annotation, :background_color, :foreground_color, :color_palette, - :group, :label, :linetype, + :group, :label, :seriestype, :seriescolor, :seriesalpha, :linecolor, :linestyle, :linewidth, :linealpha, :markershape, :markercolor, :markersize, :markeralpha, @@ -69,31 +69,31 @@ end function getLineGeom(d::KW) - lt = d[:linetype] + st = d[:seriestype] xbins, ybins = maketuple(d[:bins]) - if lt == :hexb + if st == :hexb Gadfly.Geom.hexbin(xbincount = xbins, ybincount = ybins) - elseif lt == :hist2d + elseif st == :hist2d Gadfly.Geom.histogram2d(xbincount = xbins, ybincount = ybins) - elseif lt == :hist + elseif st == :hist Gadfly.Geom.histogram(bincount = xbins, orientation = isvertical(d) ? :vertical : :horizontal, position = d[:bar_position] == :stack ? :stack : :dodge) - elseif lt == :path + elseif st == :path Gadfly.Geom.path - elseif lt in (:bar, :sticks) + elseif st in (:bar, :sticks) Gadfly.Geom.bar - elseif lt == :steppost + elseif st == :steppost Gadfly.Geom.step - elseif lt == :steppre + elseif st == :steppre Gadfly.Geom.step(direction = :vh) - elseif lt == :hline + elseif st == :hline Gadfly.Geom.hline - elseif lt == :vline + elseif st == :vline Gadfly.Geom.vline - elseif lt == :contour + elseif st == :contour Gadfly.Geom.contour(levels = d[:levels]) - # elseif lt == :shape + # elseif st == :shape # Gadfly.Geom.polygon(fill = true, preserve_order = true) else nothing @@ -116,13 +116,13 @@ function get_extra_theme_args(d::KW, k::Symbol) end function getGadflyLineTheme(d::KW) - lt = d[:linetype] + st = d[:seriestype] lc = convertColor(getColor(d[:linecolor]), d[:linealpha]) fc = convertColor(getColor(d[:fillcolor]), d[:fillalpha]) Gadfly.Theme(; - default_color = (lt in (:hist,:hist2d,:hexbin,:bar,:sticks) ? fc : lc), - line_width = (lt == :sticks ? 1 : d[:linewidth]) * Gadfly.px, + default_color = (st in (:hist,:hist2d,:hexbin,:bar,:sticks) ? fc : lc), + line_width = (st == :sticks ? 1 : d[:linewidth]) * Gadfly.px, # line_style = Gadfly.get_stroke_vector(d[:linestyle]), lowlight_color = x->RGB(fc), # fill/ribbon lowlight_opacity = alpha(fc), # fill/ribbon @@ -136,10 +136,10 @@ function addGadflyLine!(plt::Plot, numlayers::Int, d::KW, geoms...) gplt = getGadflyContext(plt) gfargs = vcat(geoms..., getGadflyLineTheme(d)) kwargs = KW() - lt = d[:linetype] + st = d[:seriestype] # add a fill? - if d[:fillrange] != nothing && lt != :contour + if d[:fillrange] != nothing && st != :contour fillmin, fillmax = map(makevec, maketuple(d[:fillrange])) nmin, nmax = length(fillmin), length(fillmax) kwargs[:ymin] = Float64[min(y, fillmin[mod1(i, nmin)], fillmax[mod1(i, nmax)]) for (i,y) in enumerate(d[:y])] @@ -147,20 +147,20 @@ function addGadflyLine!(plt::Plot, numlayers::Int, d::KW, geoms...) push!(gfargs, Gadfly.Geom.ribbon) end - if lt in (:hline, :vline) - kwargs[lt == :hline ? :yintercept : :xintercept] = d[:y] + if st in (:hline, :vline) + kwargs[st == :hline ? :yintercept : :xintercept] = d[:y] else - if lt == :sticks + if st == :sticks w = 0.01 * mean(diff(d[:x])) kwargs[:xmin] = d[:x] - w kwargs[:xmax] = d[:x] + w - elseif lt == :contour + elseif st == :contour kwargs[:z] = d[:z].surf addGadflyContColorScale(plt, d[:linecolor]) end - kwargs[:x] = d[lt == :hist ? :y : :x] + kwargs[:x] = d[st == :hist ? :y : :x] kwargs[:y] = d[:y] end @@ -183,7 +183,7 @@ getMarkerGeom(other) = gadflyshape(get_shape(other)) # getMarkerGeom(shape::Symbol) = gadflyshape(_shapes[shape]) # getMarkerGeom(shapes::AVec) = gadflyshape(map(gadflyshape, shapes)) # map(getMarkerGeom, shapes) function getMarkerGeom(d::KW) - if d[:linetype] == :shape + if d[:seriestype] == :shape Gadfly.Geom.polygon(fill = true, preserve_order = true) else getMarkerGeom(d[:markershape]) @@ -297,21 +297,21 @@ function addGadflySeries!(plt::Plot, d::KW) end # special handling for ohlc and scatter - lt = d[:linetype] - if lt == :ohlc + st = d[:seriestype] + if st == :ohlc error("Haven't re-implemented after refactoring") - elseif lt in (:hist2d, :hexbin) && (isa(d[:fillcolor], ColorGradient) || isa(d[:fillcolor], ColorFunction)) + elseif st in (:hist2d, :hexbin) && (isa(d[:fillcolor], ColorGradient) || isa(d[:fillcolor], ColorFunction)) push!(gplt.scales, Gadfly.Scale.ContinuousColorScale(p -> RGB(getColorZ(d[:fillcolor], p)))) - elseif lt == :scatter && d[:markershape] == :none + elseif st == :scatter && d[:markershape] == :none d[:markershape] = :ellipse end # markers - if d[:markershape] != :none || lt == :shape + if d[:markershape] != :none || st == :shape prepend!(layers, addGadflyMarker!(plt, length(gplt.layers), d, plt.plotargs, smooth...)) end - lt in (:hist2d, :hexbin, :contour) || addToGadflyLegend(plt, d) + st in (:hist2d, :hexbin, :contour) || addToGadflyLegend(plt, d) # now save the layers that apply to this series d[:gadflylayers] = layers diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index 1f2d9523..b77667c7 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -17,7 +17,7 @@ supportedArgs(::GLVisualizeBackend) = [ # :legend, # :linecolor, # :linestyle, - :linetype + :seriestype # :seriescolor, :seriesalpha, # :linewidth, # :linealpha, diff --git a/src/backends/gr.jl b/src/backends/gr.jl index ece9500d..7c3dfc3b 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -10,7 +10,7 @@ supportedArgs(::GRBackend) = [ :foreground_color_text, :foreground_color_border, :group, :label, - :linetype, + :seriestype, :seriescolor, :seriesalpha, :linecolor, :linestyle, :linewidth, :linealpha, :markershape, :markercolor, :markersize, :markeralpha, @@ -56,7 +56,7 @@ function _initialize_backend(::GRBackend; kw...) end end -const gr_linetype = KW( +const gr_seriestype = KW( :auto => 1, :solid => 1, :dash => 2, :dot => 3, :dashdot => 4, :dashdotdot => -1 ) @@ -139,7 +139,7 @@ end function gr_polaraxes(rmin, rmax) GR.savestate() - GR.setlinetype(GR.LINETYPE_SOLID) + GR.setseriestype(GR.LINETYPE_SOLID) GR.setlinecolorind(88) tick = 0.5 * GR.tick(rmin, rmax) n = round(Int, (rmax - rmin) / tick + 0.5) @@ -246,21 +246,21 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, xmin = ymin = typemax(Float64) xmax = ymax = typemin(Float64) for p in plt.seriesargs - lt = p[:linetype] + st = p[:seriestype] if get(d, :polar, false) - lt = :polar + st = :polar end if axis == gr_getaxisind(p) if axis == 2 num_axes = 2 end - if lt == :bar + if st == :bar x, y = 1:length(p[:y]), p[:y] - elseif lt == :ohlc + elseif st == :ohlc x, y = 1:size(p[:y], 1), p[:y] - elseif lt in [:hist, :density] + elseif st in [:hist, :density] x, y = Base.hist(p[:y], p[:bins]) - elseif lt in [:hist2d, :hexbin] + elseif st in [:hist2d, :hexbin] E = zeros(length(p[:x]),2) E[:,1] = p[:x] E[:,2] = p[:y] @@ -271,26 +271,26 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, end cmap = true x, y, H = Base.hist2d(E, xbins, ybins) - elseif lt in [:pie, :polar] + elseif st in [:pie, :polar] axes_2d = false xmin, xmax, ymin, ymax = 0, 1, 0, 1 x, y = p[:x], p[:y] else - if lt in [:contour, :surface, :heatmap] + if st in [:contour, :surface, :heatmap] cmap = true end - if lt in [:surface, :wireframe, :path3d, :scatter3d] + if st in [:surface, :wireframe, :path3d, :scatter3d] axes_2d = false end - if lt == :heatmap + if st == :heatmap outside_ticks = true end x, y = p[:x], p[:y] end - if !(lt in [:pie, :polar]) + if !(st in [:pie, :polar]) xmin = min(minimum(x), xmin) xmax = max(maximum(x), xmax) - if lt == :ohlc + if st == :ohlc for val in y ymin = min(val.open, val.high, val.low, val.close, ymin) ymax = max(val.open, val.high, val.low, val.close, ymax) @@ -437,8 +437,8 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, legend = false for p in plt.seriesargs - lt = p[:linetype] - if lt in (:hist2d, :hexbin, :contour, :surface, :wireframe, :heatmap) + st = p[:seriestype] + if st in (:hist2d, :hexbin, :contour, :surface, :wireframe, :heatmap) if isa(p[:fillcolor], ColorGradient) grad = p[:fillcolor] else @@ -450,17 +450,17 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, end end if get(d, :polar, false) - lt = :polar + st = :polar end GR.savestate() xmin, xmax, ymin, ymax = extrema[gr_getaxisind(p),:] GR.setwindow(xmin, xmax, ymin, ymax) - if lt in [:path, :line, :steppre, :steppost, :sticks, :hline, :vline, :ohlc, :polar] - GR.setlinetype(gr_linetype[p[:linestyle]]) + if st in [:path, :line, :steppre, :steppost, :sticks, :hline, :vline, :ohlc, :polar] + GR.setseriestype(gr_seriestype[p[:linestyle]]) GR.setlinewidth(p[:linewidth]) GR.setlinecolorind(gr_getcolorind(p[:linecolor])) end - if lt == :path + if st == :path if length(p[:x]) > 1 if p[:fillrange] != nothing GR.setfillcolorind(gr_getcolorind(p[:fillcolor])) @@ -471,19 +471,19 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, end legend = true end - if lt == :line + if st == :line if length(p[:x]) > 1 gr_polyline(p[:x], p[:y]) end legend = true - elseif lt in [:steppre, :steppost] + elseif st in [:steppre, :steppost] n = length(p[:x]) x = zeros(2*n + 1) y = zeros(2*n + 1) x[1], y[1] = p[:x][1], p[:y][1] j = 2 for i = 2:n - if lt == :steppre + if st == :steppre x[j], x[j+1] = p[:x][i-1], p[:x][i] y[j], y[j+1] = p[:y][i], p[:y][i] else @@ -496,13 +496,13 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, GR.polyline(x, y) end legend = true - elseif lt == :sticks + elseif st == :sticks x, y = p[:x], p[:y] for i = 1:length(y) GR.polyline([x[i], x[i]], [ymin, y[i]]) end legend = true - elseif lt == :scatter || (p[:markershape] != :none && axes_2d) + elseif st == :scatter || (p[:markershape] != :none && axes_2d) GR.setmarkercolorind(gr_getcolorind(p[:markercolor])) gr_setmarkershape(p) if typeof(p[:markersize]) <: Number @@ -523,7 +523,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, end end legend = true - elseif lt == :bar + elseif st == :bar y = p[:y] for i = 1:length(y) GR.setfillcolorind(gr_getcolorind(p[:fillcolor])) @@ -533,7 +533,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, GR.setfillintstyle(GR.INTSTYLE_HOLLOW) GR.fillrect(i-0.4, i+0.4, max(0, ymin), y[i]) end - elseif lt in [:hist, :density] + elseif st in [:hist, :density] h = Base.hist(p[:y], p[:bins]) x, y = float(collect(h[1])), float(h[2]) for i = 2:length(y) @@ -544,15 +544,15 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, GR.setfillintstyle(GR.INTSTYLE_HOLLOW) GR.fillrect(x[i-1], x[i], ymin, y[i]) end - elseif lt in [:hline, :vline] + elseif st in [:hline, :vline] for xy in p[:y] - if lt == :hline + if st == :hline GR.polyline([xmin, xmax], [xy, xy]) else GR.polyline([xy, xy], [ymin, ymax]) end end - elseif lt in [:hist2d, :hexbin] + elseif st in [:hist2d, :hexbin] E = zeros(length(p[:x]),2) E[:,1] = p[:x] E[:,2] = p[:y] @@ -573,7 +573,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, charheight = max(0.016 * diag, 0.01) GR.setcharheight(charheight) GR.colormap() - elseif lt == :contour + elseif st == :contour x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false) zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), false) GR.setspace(zmin, zmax, 0, 90) @@ -593,7 +593,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, charheight = max(0.016 * diag, 0.01) GR.setcharheight(charheight) GR.axes(0, ztick, xmax, zmin, 0, 1, 0.005) - elseif lt in [:surface, :wireframe] + elseif st in [:surface, :wireframe] x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false) zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true) GR.setspace(zmin, zmax, 40, 70) @@ -609,7 +609,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0) end z = reshape(z, length(x) * length(y)) - if lt == :surface + if st == :surface GR.gr3.surface(x, y, z, GR.OPTION_COLORED_MESH) else GR.setfillcolorind(0) @@ -624,7 +624,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, viewport[3], viewport[4]) GR.colormap() end - elseif lt == :heatmap + elseif st == :heatmap x, y, z = p[:x], p[:y], transpose_z(p, p[:z].surf, false) zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true) GR.setspace(zmin, zmax, 0, 90) @@ -635,7 +635,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, viewport[3], viewport[4]) GR.colormap() end - elseif lt in [:path3d, :scatter3d] + elseif st in [:path3d, :scatter3d] x, y, z = p[:x], p[:y], p[:z] zmin, zmax = gr_getzlims(d, minimum(z), maximum(z), true) GR.setspace(zmin, zmax, 40, 70) @@ -646,11 +646,11 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, charheight = max(0.018 * diag, 0.01) ticksize = 0.01 * (viewport[2] - viewport[1]) GR.setlinewidth(1) - if grid_flag && lt == :path3d + if grid_flag && st == :path3d GR.grid3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2) GR.grid3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0) end - if lt == :scatter3d + if st == :scatter3d GR.setmarkercolorind(gr_getcolorind(p[:markercolor])) gr_setmarkershape(p) for i = 1:length(z) @@ -667,7 +667,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, GR.setcharheight(charheight) GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize) GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize) - elseif lt == :ohlc + elseif st == :ohlc y = p[:y] n = size(y, 1) ticksize = 0.5 * (xmax - xmin) / n @@ -676,7 +676,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, GR.polyline([i, i], [y[i].low, y[i].high]) GR.polyline([i, i+ticksize], [y[i].close, y[i].close]) end - elseif lt == :pie + elseif st == :pie GR.selntran(0) GR.setfillintstyle(GR.INTSTYLE_SOLID) xmin, xmax, ymin, ymax = viewport @@ -721,7 +721,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, a1 = a2 end GR.selntran(1) - elseif lt == :polar + elseif st == :polar xmin, xmax, ymin, ymax = viewport ymax -= 0.05 * (xmax - xmin) xcenter = 0.5 * (xmin + xmax) @@ -772,7 +772,7 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, GR.setfillintstyle(GR.INTSTYLE_SOLID) GR.setfillcolorind(gr_getcolorind(d[:background_color_legend])) GR.fillrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n) - GR.setlinetype(1) + GR.setseriestype(1) GR.setlinewidth(1) GR.drawrect(px - 0.08, px + w + 0.02, py + dy, py - dy * n) i = 0 @@ -781,15 +781,15 @@ function gr_display(plt::Plot{GRBackend}, clear=true, update=true, continue end GR.setlinewidth(p[:linewidth]) - if p[:linetype] in [:path, :line, :steppre, :steppost, :sticks] + if p[:seriestype] in [:path, :line, :steppre, :steppost, :sticks] GR.setlinecolorind(gr_getcolorind(p[:linecolor])) - GR.setlinetype(gr_linetype[p[:linestyle]]) + GR.setseriestype(gr_seriestype[p[:linestyle]]) GR.polyline([px - 0.07, px - 0.01], [py, py]) end - if p[:linetype] == :scatter || p[:markershape] != :none + if p[:seriestype] == :scatter || p[:markershape] != :none GR.setmarkercolorind(gr_getcolorind(p[:markercolor])) gr_setmarkershape(p) - if p[:linetype] in [:path, :line, :steppre, :steppost, :sticks] + if p[:seriestype] in [:path, :line, :steppre, :steppost, :sticks] gr_polymarker(p, [px - 0.06, px - 0.02], [py, py]) else gr_polymarker(p, [px - 0.06, px - 0.04, px - 0.02], [py, py, py]) diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index a5591e03..acb8306b 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -17,7 +17,7 @@ supportedArgs(::PGFPlotsBackend) = [ :seriescolor, :seriesalpha, :linecolor, :linestyle, - :linetype, + :seriestype, :linewidth, :linealpha, :markershape, @@ -184,7 +184,7 @@ function _pgfplots_get_plot_kwargs(plt) end function _pgfplots_axis(plt_series) - line_type = plt_series[:linetype] + line_type = plt_series[:seriestype] plt_kwargs = _pgfplots_get_plot_kwargs(plt_series) if line_type == :path PGFPlots.Linear(plt_series[:x], plt_series[:y]; plt_kwargs...) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 01e76e98..7c4466c5 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -9,7 +9,7 @@ supportedArgs(::PlotlyBackend) = [ # :foreground_color_text, :foreground_color_border, :group, :label, - :linetype, + :seriestype, :seriescolor, :seriesalpha, :linecolor, :linestyle, :linewidth, :linealpha, :markershape, :markercolor, :markersize, :markeralpha, @@ -323,7 +323,7 @@ function plotly_layout(d::KW, seriesargs::AVec{KW}) # # arrows # for sargs in seriesargs # a = sargs[:arrow] - # if sargs[:linetype] in (:path, :line) && typeof(a) <: Arrow + # if sargs[:seriestype] in (:path, :line) && typeof(a) <: Arrow # add_arrows(sargs[:x], sargs[:y]) do xyprev, xy # push!(d_out[:annotations], get_annotation_dict_for_arrow(sargs, xyprev, xy, a)) # end @@ -367,13 +367,13 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing) x, y = collect(d[:x]), collect(d[:y]) d_out[:name] = d[:label] - lt = d[:linetype] - isscatter = lt in (:scatter, :scatter3d) + st = d[:seriestype] + isscatter = st in (:scatter, :scatter3d) hasmarker = isscatter || d[:markershape] != :none hasline = !isscatter # set the "type" - if lt in (:line, :path, :scatter, :steppre, :steppost) + if st in (:line, :path, :scatter, :steppre, :steppost) d_out[:type] = "scatter" d_out[:mode] = if hasmarker hasline ? "lines+markers" : "markers" @@ -388,11 +388,11 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing) end d_out[:x], d_out[:y] = x, y - elseif lt == :bar + elseif st == :bar d_out[:type] = "bar" d_out[:x], d_out[:y] = x, y - elseif lt == :hist2d + elseif st == :hist2d d_out[:type] = "histogram2d" d_out[:x], d_out[:y] = x, y if isa(d[:bins], Tuple) @@ -403,22 +403,22 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing) d_out[:nbinsx] = xbins d_out[:nbinsy] = ybins - elseif lt in (:hist, :density) + elseif st in (:hist, :density) d_out[:type] = "histogram" isvert = isvertical(d) d_out[isvert ? :x : :y] = y d_out[isvert ? :nbinsx : :nbinsy] = d[:bins] - if lt == :density + if st == :density d_out[:histnorm] = "probability density" end - elseif lt == :heatmap + elseif st == :heatmap d_out[:type] = "heatmap" d_out[:x], d_out[:y] = x, y d_out[:z] = d[:z].surf d_out[:colorscale] = plotly_colorscale(d[:fillcolor], d[:fillalpha]) - elseif lt == :contour + elseif st == :contour d_out[:type] = "contour" d_out[:x], d_out[:y] = x, y d_out[:z] = d[:z].surf @@ -427,19 +427,19 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing) d_out[:contours] = KW(:coloring => d[:fillrange] != nothing ? "fill" : "lines") d_out[:colorscale] = plotly_colorscale(d[:linecolor], d[:linealpha]) - elseif lt in (:surface, :wireframe) + elseif st in (:surface, :wireframe) d_out[:type] = "surface" d_out[:x], d_out[:y] = x, y d_out[:z] = d[:z].surf d_out[:colorscale] = plotly_colorscale(d[:fillcolor], d[:fillalpha]) - elseif lt == :pie + elseif st == :pie d_out[:type] = "pie" d_out[:labels] = x d_out[:values] = y d_out[:hoverinfo] = "label+percent+name" - elseif lt in (:path3d, :scatter3d) + elseif st in (:path3d, :scatter3d) d_out[:type] = "scatter3d" d_out[:mode] = if hasmarker hasline ? "lines+markers" : "markers" @@ -450,7 +450,7 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing) d_out[:z] = collect(d[:z]) else - warn("Plotly: linetype $lt isn't supported.") + warn("Plotly: seriestype $st isn't supported.") return KW() end @@ -484,9 +484,9 @@ function plotly_series(d::KW, plotargs::KW; plot_index = nothing) d_out[:line] = KW( :color => webcolor(d[:linecolor], d[:linealpha]), :width => d[:linewidth], - :shape => if lt == :steppre + :shape => if st == :steppre "vh" - elseif lt == :steppost + elseif st == :steppost "hv" else "linear" diff --git a/src/backends/plotlyjs.jl b/src/backends/plotlyjs.jl index 3edc8f76..8a9a7b5a 100644 --- a/src/backends/plotlyjs.jl +++ b/src/backends/plotlyjs.jl @@ -17,7 +17,7 @@ supportedArgs(::PlotlyJSBackend) = [ :seriescolor, :seriesalpha, :linecolor, :linestyle, - :linetype, + :seriestype, :linewidth, :linealpha, :markershape, diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index b8d889fd..3b81e493 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -10,7 +10,7 @@ supportedArgs(::PyPlotBackend) = [ :foreground_color_text, :foreground_color_border, :group, :label, - :linetype, + :seriestype, :seriescolor, :seriesalpha, :linecolor, :linestyle, :linewidth, :linealpha, :markershape, :markercolor, :markersize, :markeralpha, @@ -117,8 +117,8 @@ function getPyPlotCustomShading(c, z, α=nothing) end # get the style (solid, dashed, etc) -function getPyPlotLineStyle(linetype::Symbol, linestyle::Symbol) - linetype == :none && return " " +function getPyPlotLineStyle(seriestype::Symbol, linestyle::Symbol) + seriestype == :none && return " " linestyle == :solid && return "-" linestyle == :dash && return "--" linestyle == :dot && return ":" @@ -197,9 +197,9 @@ function getPyPlotMarker(marker::AbstractString) marker end -function getPyPlotStepStyle(linetype::Symbol) - linetype == :steppost && return "steps-post" - linetype == :steppre && return "steps-pre" +function getPyPlotStepStyle(seriestype::Symbol) + seriestype == :steppost && return "steps-post" + seriestype == :steppre && return "steps-pre" return "default" end @@ -308,7 +308,7 @@ function pyplot_figure(plotargs::KW) end function pyplot_3d_setup!(wrap, d) - if trueOrAllTrue(lt -> lt in _3dTypes, get(d, :linetype, :none)) + if trueOrAllTrue(st -> st in _3dTypes, get(d, :seriestype, :none)) push!(wrap.kwargs, (:projection, "3d")) end end @@ -369,13 +369,13 @@ pymarkercolormap(d::KW) = getPyPlotColorMap(d[:markercolor], d[:markeralpha] pyfillcolormap(d::KW) = getPyPlotColorMap(d[:fillcolor], d[:fillalpha]) function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) - lt = d[:linetype] - if !(lt in supportedTypes(pkg)) - error("linetype $(lt) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))") + st = d[:seriestype] + if !(st in supportedTypes(pkg)) + error("seriestype $(st) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))") end # 3D plots have a different underlying Axes object in PyPlot - if lt in _3dTypes && isempty(plt.o.kwargs) + if st in _3dTypes && isempty(plt.o.kwargs) push!(plt.o.kwargs, (:projection, "3d")) end @@ -385,7 +385,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) ax = getAxis(plt, d[:axis]) x, y, z = d[:x], d[:y], d[:z] @show typeof((x,y,z)) - xyargs = (lt in _3dTypes ? (x,y,z) : (x,y)) + xyargs = (st in _3dTypes ? (x,y,z) : (x,y)) # handle zcolor and get c/cmap extrakw = KW() @@ -410,17 +410,17 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) # for each plotting command, optionally build and add a series handle to the list # line plot - if lt in (:path, :line, :scatter, :path3d, :scatter3d, :steppre, :steppost) + if st in (:path, :line, :scatter, :path3d, :scatter3d, :steppre, :steppost) if d[:linewidth] > 0 handle = ax[:plot](xyargs...; label = d[:label], zorder = plt.n, color = pylinecolor(d), linewidth = d[:linewidth], - linestyle = getPyPlotLineStyle(lt, d[:linestyle]), + linestyle = getPyPlotLineStyle(st, d[:linestyle]), solid_capstyle = "round", # dash_capstyle = "round", - drawstyle = getPyPlotStepStyle(lt) + drawstyle = getPyPlotStepStyle(st) )[1] push!(handles, handle) @@ -436,7 +436,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) :edgecolor => pylinecolor(d), :facecolor => pylinecolor(d), :linewidth => d[:linewidth], - :linestyle => getPyPlotLineStyle(lt, d[:linestyle]), + :linestyle => getPyPlotLineStyle(st, d[:linestyle]), ) add_arrows(x, y) do xyprev, xy ax[:annotate]("", @@ -450,7 +450,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) end end - if lt == :bar + if st == :bar extrakw[isvertical(d) ? :width : :height] = 0.9 handle = ax[isvertical(d) ? :bar : :barh](x, y; label = d[:label], @@ -464,7 +464,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) end - if lt == :sticks + if st == :sticks extrakw[isvertical(d) ? :width : :height] = 0.0 handle = ax[isvertical(d) ? :bar : :barh](x, y; label = d[:label], @@ -479,7 +479,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) end # add markers? - if d[:markershape] != :none && lt in (:path, :line, :scatter, :path3d, + if d[:markershape] != :none && st in (:path, :line, :scatter, :path3d, :scatter3d, :steppre, :steppost, :bar, :sticks) extrakw = KW() @@ -490,7 +490,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) extrakw[:cmap] = pymarkercolormap(d) needs_colorbar = true end - xyargs = if lt in (:bar, :sticks) && !isvertical(d) + xyargs = if st in (:bar, :sticks) && !isvertical(d) (y, x) else xyargs @@ -507,7 +507,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) end - if lt == :hist + if st == :hist handle = ax[:hist](y; label = d[:label], zorder = plt.n, @@ -523,7 +523,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) end - if lt == :hist2d + if st == :hist2d handle = ax[:hist2d](x, y; label = d[:label], zorder = plt.n, @@ -536,7 +536,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) needs_colorbar = true end - if lt == :hexbin + if st == :hexbin handle = ax[:hexbin](x, y; label = d[:label], zorder = plt.n, @@ -549,25 +549,25 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) needs_colorbar = true end - if lt in (:hline,:vline) + if st in (:hline,:vline) for yi in d[:y] - func = ax[lt == :hline ? :axhline : :axvline] + func = ax[st == :hline ? :axhline : :axvline] handle = func(yi; linewidth=d[:linewidth], color=pylinecolor(d), - linestyle=getPyPlotLineStyle(lt, d[:linestyle]) + linestyle=getPyPlotLineStyle(st, d[:linestyle]) ) push!(handles, handle) end end - if lt in (:contour, :contour3d) + if st in (:contour, :contour3d) # z = z.surf' z = transpose_z(d, z.surf) needs_colorbar = true - if lt == :contour3d + if st == :contour3d extrakw[:extend3d] = true end @@ -576,14 +576,14 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) label = d[:label], zorder = plt.n, linewidths = d[:linewidth], - linestyles = getPyPlotLineStyle(lt, d[:linestyle]), + linestyles = getPyPlotLineStyle(st, d[:linestyle]), cmap = pylinecolormap(d), extrakw... ) push!(handles, handle) # contour fills - # if lt == :contour + # if st == :contour handle = ax[:contourf](x, y, z, levelargs...; label = d[:label], zorder = plt.n + 0.5, @@ -594,7 +594,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) # end end - if lt in (:surface, :wireframe) + if st in (:surface, :wireframe) if typeof(z) <: AbstractMatrix || typeof(z) <: Surface x, y, z = map(Array, (x,y,z)) if !ismatrix(x) || !ismatrix(y) @@ -603,7 +603,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) end # z = z' z = transpose_z(d, z) - if lt == :surface + if st == :surface if d[:marker_z] != nothing extrakw[:facecolors] = getPyPlotCustomShading(d[:fillcolor], d[:marker_z], d[:fillalpha]) extrakw[:shade] = false @@ -612,7 +612,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) needs_colorbar = true end end - handle = ax[lt == :surface ? :plot_surface : :plot_wireframe](x, y, z; + handle = ax[st == :surface ? :plot_surface : :plot_wireframe](x, y, z; label = d[:label], zorder = plt.n, rstride = 1, @@ -654,11 +654,11 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) needs_colorbar = true else - error("Unsupported z type $(typeof(z)) for linetype=$lt") + error("Unsupported z type $(typeof(z)) for seriestype=$st") end end - if lt == :image + if st == :image img = Array(transpose_z(d, z.surf)) z = if eltype(img) <: Colors.AbstractGray float(img) @@ -673,7 +673,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) end - if lt == :heatmap + if st == :heatmap x, y, z = heatmap_edges(x), heatmap_edges(y), transpose_z(d, z.surf) if !(eltype(z) <: Number) z, discrete_colorbar_values = indices_and_unique_values(z) @@ -688,7 +688,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) needs_colorbar = true end - if lt == :shape + if st == :shape path = buildPyPlotPath(x, y) patches = pypatches.pymember("PathPatch")(path; label = d[:label], @@ -702,7 +702,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) end - if lt == :pie + if st == :pie handle = ax[:pie](y; # label = d[:label], # colors = # a vector of colors? @@ -742,7 +742,7 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) # handle area filling fillrange = d[:fillrange] - if fillrange != nothing && lt != :contour + if fillrange != nothing && st != :contour f, dim1, dim2 = if isvertical(d) :fill_between, x, y else @@ -1106,7 +1106,7 @@ function addPyPlotLegend(plt::Plot, ax) leg = plt.plotargs[:legend] if leg != :none # gotta do this to ensure both axes are included - args = filter(x -> !(x[:linetype] in ( + args = filter(x -> !(x[:seriestype] in ( :hist,:density,:hexbin,:hist2d,:hline,:vline, :contour,:contour3d,:surface,:wireframe, :heatmap,:path3d,:scatter3d, :pie, :image diff --git a/src/backends/qwt.jl b/src/backends/qwt.jl index 0a83ffa2..2fa0cd9b 100644 --- a/src/backends/qwt.jl +++ b/src/backends/qwt.jl @@ -17,7 +17,7 @@ supportedArgs(::QwtBackend) = [ :legend, :seriescolor, :seriesalpha, :linestyle, - :linetype, + :seriestype, :linewidth, :markershape, :markercolor, @@ -91,29 +91,29 @@ end function adjustQwtKeywords(plt::Plot{QwtBackend}, iscreating::Bool; kw...) d = KW(kw) - lt = d[:linetype] - if lt == :scatter - d[:linetype] = :none + st = d[:seriestype] + if st == :scatter + d[:seriestype] = :none if d[:markershape] == :none d[:markershape] = :ellipse end - elseif lt in (:hline, :vline) + elseif st in (:hline, :vline) addLineMarker(plt, d) - d[:linetype] = :none + d[:seriestype] = :none d[:markershape] = :ellipse d[:markersize] = 1 - if lt == :vline + if st == :vline d[:x], d[:y] = d[:y], d[:x] end - elseif !iscreating && lt == :bar + elseif !iscreating && st == :bar d = barHack(; kw...) - elseif !iscreating && lt == :hist + elseif !iscreating && st == :hist d = barHack(; histogramHack(; kw...)...) end - replaceQwtAliases(d, :linetype) + replaceQwtAliases(d, :seriestype) replaceQwtAliases(d, :markershape) for k in keys(d) @@ -208,7 +208,7 @@ end function addLineMarker(plt::Plot{QwtBackend}, d::KW) for yi in d[:y] marker = Qwt.QWT.QwtPlotMarker() - ishorizontal = (d[:linetype] == :hline) + ishorizontal = (d[:seriestype] == :hline) marker[:setLineStyle](ishorizontal ? 1 : 2) marker[ishorizontal ? :setYValue : :setXValue](yi) qcolor = Qwt.convertRGBToQColor(getColor(d[:linecolor])) diff --git a/src/backends/supported.jl b/src/backends/supported.jl index 8408cf18..ed518ca4 100644 --- a/src/backends/supported.jl +++ b/src/backends/supported.jl @@ -24,7 +24,7 @@ # :background_color, :foreground_color, :color_palette, # :group, # :label, -# :linetype, +# :seriestype, # :seriescolor, :seriesalpha, # :linecolor, :linestyle, :linewidth, :linealpha, # :markershape, :markercolor, :markersize, :markeralpha, @@ -81,7 +81,7 @@ # :foreground_color_text, :foreground_color_border, # :group, # :label, -# :linetype, +# :seriestype, # :seriescolor, :seriesalpha, # :linecolor, :linestyle, :linewidth, :linealpha, # :markershape, :markercolor, :markersize, :markeralpha, @@ -129,7 +129,7 @@ # :background_color, :foreground_color, :color_palette, # :group, # :label, -# :linetype, +# :seriestype, # :seriescolor, :seriesalpha, # :linecolor, :linestyle, :linewidth, :linealpha, # :markershape, :markercolor, :markersize, :markeralpha, @@ -183,7 +183,7 @@ # :legend, # :seriescolor, :seriesalpha, # :linestyle, -# :linetype, +# :seriestype, # :linewidth, # :markershape, # :markercolor, @@ -235,7 +235,7 @@ # :legend, # :seriescolor, :seriesalpha, # :linestyle, -# :linetype, +# :seriestype, # # :linewidth, # :markershape, # # :markercolor, @@ -300,7 +300,7 @@ # :legend, # :seriescolor, :seriesalpha, # :linestyle, -# :linetype, +# :seriestype, # :linewidth, # :markershape, # :markercolor, @@ -362,7 +362,7 @@ # # :legend, # :seriescolor, :seriesalpha, # :linestyle, -# :linetype, +# :seriestype, # :linewidth, # # :linealpha, # :markershape, @@ -429,7 +429,7 @@ # :seriescolor, :seriesalpha, # :linecolor, # :linestyle, -# :linetype, +# :seriestype, # :linewidth, # :linealpha, # :markershape, @@ -506,7 +506,7 @@ # :seriescolor, :seriesalpha, # :linecolor, # :linestyle, -# :linetype, +# :seriestype, # :linewidth, # :linealpha, # :markershape, @@ -581,7 +581,7 @@ # # :legend, # # :linecolor, # # :linestyle, -# :linetype +# :seriestype # # :seriescolor, :seriesalpha, # # :linewidth, # # :linealpha, @@ -648,7 +648,7 @@ # :seriescolor, :seriesalpha, # :linecolor, # :linestyle, -# :linetype, +# :seriestype, # :linewidth, # :linealpha, # :markershape, diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index 13d8b6cc..5cf26fda 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -17,7 +17,7 @@ supportedArgs(::UnicodePlotsBackend) = [ :legend, :seriescolor, :seriesalpha, :linestyle, - :linetype, + :seriestype, # :linewidth, :markershape, # :markercolor, @@ -133,12 +133,12 @@ end function addUnicodeSeries!(o, d::KW, addlegend::Bool, xlim, ylim) # get the function, or special handling for step/bar/hist - lt = d[:linetype] + st = d[:seriestype] # handle hline/vline separately - if lt in (:hline,:vline) + if st in (:hline,:vline) for yi in d[:y] - if lt == :hline + if st == :hline UnicodePlots.lineplot!(o, xlim, [yi,yi]) else UnicodePlots.lineplot!(o, [yi,yi], ylim) @@ -148,17 +148,17 @@ function addUnicodeSeries!(o, d::KW, addlegend::Bool, xlim, ylim) end stepstyle = :post - if lt == :path + if st == :path func = UnicodePlots.lineplot! - elseif lt == :scatter || d[:markershape] != :none + elseif st == :scatter || d[:markershape] != :none func = UnicodePlots.scatterplot! - elseif lt == :steppost + elseif st == :steppost func = UnicodePlots.stairs! - elseif lt == :steppre + elseif st == :steppre func = UnicodePlots.stairs! stepstyle = :pre else - error("Linestyle $lt not supported by UnicodePlots") + error("Linestyle $st not supported by UnicodePlots") end # get the series data and label @@ -193,9 +193,9 @@ function _create_plot(pkg::UnicodePlotsBackend, d::KW) end function _add_series(::UnicodePlotsBackend, plt::Plot, d::KW) - if d[:linetype] in (:sticks, :bar) + if d[:seriestype] in (:sticks, :bar) d = barHack(; d...) - elseif d[:linetype] == :hist + elseif d[:seriestype] == :hist d = barHack(; histogramHack(; d...)...) end push!(plt.seriesargs, d) diff --git a/src/backends/winston.jl b/src/backends/winston.jl index 1c662e90..fe6222e7 100644 --- a/src/backends/winston.jl +++ b/src/backends/winston.jl @@ -21,7 +21,7 @@ supportedArgs(::WinstonBackend) = [ :legend, :seriescolor, :seriesalpha, :linestyle, - :linetype, + :seriestype, :linewidth, :markershape, :markercolor, @@ -130,7 +130,7 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW) window, canvas, wplt = getWinstonItems(plt) # until we call it normally, do the hack - if d[:linetype] == :bar + if d[:seriestype] == :bar d = barHack(;d...) end @@ -149,10 +149,10 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW) ## lintype :path, :step, :stepinverted, :sticks, :dots, :none, :hist2d, :hexbin, :hist, :bar - if d[:linetype] == :none + if d[:seriestype] == :none Winston.add(wplt, Winston.Points(d[:x], d[:y]; copy_remove(e, :kind)..., color=getColor(d[:markercolor]))) - elseif d[:linetype] == :path + elseif d[:seriestype] == :path x, y = d[:x], d[:y] Winston.add(wplt, Winston.Curve(x, y; e...)) @@ -166,38 +166,38 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW) Winston.add(wplt, Winston.FillBetween(x, y, x, y2, fillcolor=getColor(d[:fillcolor]))) end - elseif d[:linetype] == :scatter + elseif d[:seriestype] == :scatter if d[:markershape] == :none d[:markershape] = :ellipse end - # elseif d[:linetype] == :step + # elseif d[:seriestype] == :step # fn = Winston.XXX - # elseif d[:linetype] == :stepinverted + # elseif d[:seriestype] == :stepinverted # fn = Winston.XXX - elseif d[:linetype] == :sticks + elseif d[:seriestype] == :sticks Winston.add(wplt, Winston.Stems(d[:x], d[:y]; e...)) - # elseif d[:linetype] == :dots + # elseif d[:seriestype] == :dots # fn = Winston.XXX - # elseif d[:linetype] == :hist2d + # elseif d[:seriestype] == :hist2d # fn = Winston.XXX - # elseif d[:linetype] == :hexbin + # elseif d[:seriestype] == :hexbin # fn = Winston.XXX - elseif d[:linetype] == :hist + elseif d[:seriestype] == :hist hst = hist(d[:y], d[:bins]) Winston.add(wplt, Winston.Histogram(hst...; copy_remove(e, :bins)...)) - # elseif d[:linetype] == :bar + # elseif d[:seriestype] == :bar # # fn = Winston.XXX else - error("linetype $(d[:linetype]) not supported by Winston.") + error("seriestype $(d[:seriestype]) not supported by Winston.") end @@ -209,7 +209,7 @@ function _add_series(::WinstonBackend, plt::Plot, d::KW) # optionally add a regression line - d[:smooth] && d[:linetype] != :hist && addRegressionLineWinston(d, wplt) + d[:smooth] && d[:seriestype] != :hist && addRegressionLineWinston(d, wplt) push!(plt.seriesargs, d) plt diff --git a/src/plot.jl b/src/plot.jl index 47f43bcf..74e5f020 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -126,21 +126,21 @@ function _add_plotargs!(plt::Plot, d::KW) end end -# this method recursively applies series recipes when the linetype is not supported +# this method recursively applies series recipes when the seriestype is not supported # natively by the backend function _apply_series_recipe(plt::Plot, d::KW) - lt = d[:linetype] + st = d[:seriestype] # dumpdict(d, "apply_series_recipe", true) - if lt in supportedTypes() + if st in supportedTypes() # println("adding series!!") warnOnUnsupported(plt.backend, d) _add_series(plt.backend, plt, d) else - # get a sub list of series for this linetype + # get a sub list of series for this seriestype series_list = try - RecipesBase.apply_recipe(d, Val{lt}, d[:x], d[:y], d[:z]) + RecipesBase.apply_recipe(d, Val{st}, d[:x], d[:y], d[:z]) catch - warn("Exception during apply_recipe(Val{$lt}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))") + warn("Exception during apply_recipe(Val{$st}, ...) with types ($(typeof(d[:x])), $(typeof(d[:y])), $(typeof(d[:z])))") rethrow() end @@ -159,7 +159,7 @@ function _plot!(plt::Plot, d::KW, args...) # just in case the backend needs to set up the plot (make it current or something) _before_add_series(plt) - # TODO: the grouping mechanism will be a recipe on a GroupBy object + # the grouping mechanism is a recipe on a GroupBy object # we simply add the GroupBy object to the front of the args list to allow # the recipe to be applied if haskey(d, :group) @@ -174,7 +174,6 @@ function _plot!(plt::Plot, d::KW, args...) else delete!(d, :annotation) end - # anns = annotations(pop!(d, :annotation, []) # for plotting recipes, swap out the args and update the parameter dictionary @@ -186,41 +185,52 @@ function _plot!(plt::Plot, d::KW, args...) kw_list = KW[] still_to_process = isempty(args) ? [] : [RecipeData(copy(d), args)] while !isempty(still_to_process) + + # grab the first in line to be processed and pass it through apply_recipe + # to generate a list of RecipeData objects (data + attributes) next_series = pop!(still_to_process) series_list = RecipesBase.apply_recipe(next_series.d, next_series.args...) for series in series_list # @show series if isempty(series.args) - # finish processing and add to the kw_list + # when the arg tuple is empty, that means there's nothing left to recursively + # process... finish up and add to the kw_list kw = series.d _add_markershape(kw) + + # if there was a grouping, filter the data here _filter_input_data!(kw) + # map marker_z if it's a Function if isa(get(kw, :marker_z, nothing), Function) # TODO: should this take y and/or z as arguments? kw[:marker_z] = map(kw[:marker_z], kw[:x]) end + # convert a ribbon into a fillrange if get(kw, :ribbon, nothing) != nothing rib = kw[:ribbon] kw[:fillrange] = (kw[:y] - rib, kw[:y] + rib) end + # check that the backend will support the command and add it to the list warnOnUnsupportedArgs(plt.backend, kw) warnOnUnsupportedScales(plt.backend, kw) push!(kw_list, kw) - # handle error bars + # handle error bars by creating new series data... these will have + # the same series index as the series they are copied from for esym in (:xerror, :yerror) if get(d, esym, nothing) != nothing # we make a copy of the KW and apply an errorbar recipe errkw = copy(kw) - errkw[:linetype] = esym + errkw[:seriestype] = esym push!(kw_list, errkw) - # append!(ret, apply_series_recipe(copy(d), Val{esym})) end end + else + # args are non-empty, so there's still processing to do... add it back to the queue push!(still_to_process, series) end end @@ -229,93 +239,77 @@ function _plot!(plt::Plot, d::KW, args...) # !!! note: at this point, kw_list is fully decomposed into individual series... one KW per series !!! - # # # grouping - # groupby = if haskey(d, :group) - # extractGroupArgs(d[:group], args...) - # else - # nothing - # end - - - - # now include any annotations which were added during recipes - # anns = NTuple{3,Any}[] for kw in kw_list append!(anns, annotations(pop!(kw, :annotation, []))) end # @show anns + # merge plot args... this is where we combine all the plot args from the user and + # from the recipes... axis info, colors, etc # TODO: why do i need to check for the subplot key? - - # merge plot args if !haskey(d, :subplot) - # merge the plot args from the recipes, then update the plot colors for kw in vcat(kw_list, d) - # @show kw - # append!(anns, annotations(pop!(kw, :annotation, []))) _add_plotargs!(plt, kw) end handlePlotColors(plt.backend, plt.plotargs) end - # _add_series(plt, d, args...) # this is it folks! # TODO: we probably shouldn't use i for tracking series index, but rather explicitly track it in recipes for (i,kw) in enumerate(kw_list) - if !(get(kw, :linetype, :none) in (:xerror, :yerror)) + if !(get(kw, :seriestype, :none) in (:xerror, :yerror)) plt.n += 1 end - # TODO: can this be handled as a recipe?? + # TODO: can this be handled as a recipe?? (yes... need to remove) # note: this could probably be handled using a recipe signature f{S<:Union{AbstractString,Symbol}}(v::AVec{S}, letter::AbstractString) # that gets called from within the SliceIt section - # if !stringsSupported() && di[:linetype] != :pie + # if !stringsSupported() && di[:seriestype] != :pie # setTicksFromStringVector(plt, d, di, "x") # setTicksFromStringVector(plt, d, di, "y") # setTicksFromStringVector(plt, d, di, "z") # end - # TODO: unnecessary?? + # TODO: unnecessary?? (yes... deleted as part of _add_plotargs... remove this) # # remove plot args # for k in keys(_plotDefaults) # delete!(di, k) # end - # TODO: why?? + # TODO: why?? (I think we can remove??) # # merge in plotarg_overrides # plotarg_overrides = pop!(di, :plotarg_overrides, nothing) # if plotarg_overrides != nothing # merge!(plt.plotargs, plotarg_overrides) # end - # dumpdict(kw, "before add defaults", true) + # set default values, select from attribute cycles, and generally set the final attributes _add_defaults!(kw, plt, i) - # dumpdict(kw, "after add defaults", true) - # getSeriesArgs(plt.backend, getplotargs(plt, n), d, commandIndex, convertSeriesIndex(plt, n), n) _replace_linewidth(kw) - # todo: while the linetype is not supported, try to apply a recipe of f(Val{lt}, x,y,z) recursively - # the default should throw an error because we can't handle that linetype + # now we have a fully specified series, with colors chosen. we must recursively handle + # series recipes, which dispatch on seriestype. If a backend does not natively support a seriestype, + # we check for a recipe that will convert that series type into one made up of lower-level components. + # For example, a histogram is just a bar plot with binned data, a bar plot is really a filled step plot, + # and a step plot is really just a path. So any backend that supports drawing a path will implicitly + # be able to support step, bar, and histogram plots (and any recipes that use those components). _apply_series_recipe(plt, kw) - - - # _add_series(plt.backend, plt, kw) end + # now that we're done adding all the series, add the annotations _add_annotations(plt, anns) # add title, axis labels, ticks, etc + # TODO: do we really need this subplot check? if !haskey(d, :subplot) # merge!(plt.plotargs, d) # this shouldn't be needed since we merged the keys earlier _update_plot(plt, plt.plotargs) end - # _update_plot_pos_size(plt, d) # this is only used for Qwt... can we remove? - current(plt) # note: lets ignore the show param and effectively use the semicolon at the end of the REPL statement @@ -343,7 +337,7 @@ end function _replace_linewidth(d::KW) # get a good default linewidth... 0 for surface and heatmaps if get(d, :linewidth, :auto) == :auto - d[:linewidth] = (get(d, :linetype, :path) in (:surface,:heatmap,:image) ? 0 : 1) + d[:linewidth] = (get(d, :seriestype, :path) in (:surface,:heatmap,:image) ? 0 : 1) end end @@ -379,7 +373,7 @@ end # for (i,di) in enumerate(seriesArgList) # plt.n += 1 # -# if !stringsSupported() && di[:linetype] != :pie +# if !stringsSupported() && di[:seriestype] != :pie # setTicksFromStringVector(plt, d, di, "x") # setTicksFromStringVector(plt, d, di, "y") # setTicksFromStringVector(plt, d, di, "z") @@ -407,63 +401,63 @@ end # -------------------------------------------------------------------- -function get_indices(orig, labels) - Int[findnext(labels, l, 1) for l in orig] -end +# function get_indices(orig, labels) +# Int[findnext(labels, l, 1) for l in orig] +# end -function setTicksFromStringVector(plt::Plot, d::KW, di::KW, letter) - sym = symbol(letter) - ticksym = symbol(letter * "ticks") - pargs = plt.plotargs - v = di[sym] +# # TODO: remove?? this is the old way of handling discrete data... should be +# # replaced by the Axis type and logic +# function setTicksFromStringVector(plt::Plot, d::KW, di::KW, letter) +# sym = symbol(letter) +# ticksym = symbol(letter * "ticks") +# pargs = plt.plotargs +# v = di[sym] +# +# # do we really want to do this? +# typeof(v) <: AbstractArray || return +# isempty(v) && return +# trueOrAllTrue(_ -> typeof(_) <: AbstractString, v) || return +# +# # compute the ticks and labels +# ticks, labels = if ticksType(pargs[ticksym]) == :ticks_and_labels +# # extend the existing ticks and labels. only add to labels if they're new! +# ticks, labels = pargs[ticksym] +# newlabels = filter(_ -> !(_ in labels), unique(v)) +# newticks = if isempty(ticks) +# collect(1:length(newlabels)) +# else +# maximum(ticks) + collect(1:length(newlabels)) +# end +# ticks = vcat(ticks, newticks) +# labels = vcat(labels, newlabels) +# ticks, labels +# else +# # create new ticks and labels +# newlabels = unique(v) +# collect(1:length(newlabels)), newlabels +# end +# +# d[ticksym] = ticks, labels +# plt.plotargs[ticksym] = ticks, labels +# +# # add an origsym field so that later on we can re-compute the x vector if ticks change +# origsym = symbol(letter * "orig") +# di[origsym] = v +# di[sym] = get_indices(v, labels) +# +# # loop through existing plt.seriesargs and adjust indices if there is an origsym key +# for sargs in plt.seriesargs +# if haskey(sargs, origsym) +# # TODO: might need to call the setindex function instead to trigger a plot update for some backends?? +# sargs[sym] = get_indices(sargs[origsym], labels) +# end +# end +# end - # do we really want to do this? - typeof(v) <: AbstractArray || return - isempty(v) && return - trueOrAllTrue(_ -> typeof(_) <: AbstractString, v) || return - - # compute the ticks and labels - ticks, labels = if ticksType(pargs[ticksym]) == :ticks_and_labels - # extend the existing ticks and labels. only add to labels if they're new! - ticks, labels = pargs[ticksym] - newlabels = filter(_ -> !(_ in labels), unique(v)) - newticks = if isempty(ticks) - collect(1:length(newlabels)) - else - maximum(ticks) + collect(1:length(newlabels)) - end - ticks = vcat(ticks, newticks) - labels = vcat(labels, newlabels) - ticks, labels - else - # create new ticks and labels - newlabels = unique(v) - collect(1:length(newlabels)), newlabels - end - - d[ticksym] = ticks, labels - plt.plotargs[ticksym] = ticks, labels - - # add an origsym field so that later on we can re-compute the x vector if ticks change - origsym = symbol(letter * "orig") - di[origsym] = v - di[sym] = get_indices(v, labels) - - # loop through existing plt.seriesargs and adjust indices if there is an origsym key - for sargs in plt.seriesargs - if haskey(sargs, origsym) - # TODO: might need to call the setindex function instead to trigger a plot update for some backends?? - sargs[sym] = get_indices(sargs[origsym], labels) - end - end -end - -# -------------------------------------------------------------------- - -_before_add_series(plt::Plot) = nothing # -------------------------------------------------------------------- +# TODO: remove # # should we update the x/y label given the meta info during input slicing? # function updateDictWithMeta(d::KW, plotargs::KW, meta::Symbol, isx::Bool) # lsym = isx ? :xlabel : :ylabel diff --git a/src/recipes.jl b/src/recipes.jl index 3feaaff0..3b4d4889 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -211,10 +211,10 @@ end # # Returns a Vector{KW}. # """ -# apply_series_recipe(d::KW, lt) = KW[d] +# apply_series_recipe(d::KW, st) = KW[d] -# for linetype `line`, need to sort by x values +# for seriestype `line`, need to sort by x values @recipe function f(::Type{Val{:line}}, x, y, z) # order by x indices = sortperm(d[:x]) @@ -223,7 +223,7 @@ end if typeof(d[:z]) <: AVec d[:z] = d[:z][indices] end - d[:linetype] = :path + d[:seriestype] = :path () end @@ -266,7 +266,7 @@ const _box_halfwidth = 0.4 # d[:plotarg_overrides] = KW(:xticks => (1:length(shapes), groupby.groupLabels)) - d[:linetype] = :shape + d[:seriestype] = :shape n = length(groupby.groupLabels) xticks --> (linspace(0.5,n-0.5,n), groupby.groupLabels) @@ -323,7 +323,7 @@ end end # d[:plotarg_overrides] = KW(:xticks => (1:length(shapes), groupby.groupLabels)) - d[:linetype] = :shape + d[:seriestype] = :shape n = length(groupby.groupLabels) xticks --> (linspace(0.5,n-0.5,n), groupby.groupLabels) @@ -337,7 +337,7 @@ end # Error Bars function error_style!(d::KW) - d[:linetype] = :path + d[:seriestype] = :path d[:linecolor] = d[:markerstrokecolor] d[:linewidth] = d[:markerstrokewidth] d[:label] = "" @@ -401,7 +401,7 @@ end # function apply_series_recipe(d::KW, ::Type{Val{:quiver}}) function quiver_using_arrows(d::KW) d[:label] = "" - d[:linetype] = :path + d[:seriestype] = :path if !isa(d[:arrow], Arrow) d[:arrow] = arrow() end @@ -440,7 +440,7 @@ end # function apply_series_recipe(d::KW, ::Type{Val{:quiver}}) function quiver_using_hack(d::KW) d[:label] = "" - d[:linetype] = :shape + d[:seriestype] = :shape velocity = error_zipit(d[:quiver]) xorig, yorig = d[:x], d[:y] diff --git a/src/series_args.jl b/src/series_args.jl index e24a230a..9fd32046 100644 --- a/src/series_args.jl +++ b/src/series_args.jl @@ -7,7 +7,7 @@ typealias FuncOrFuncs @compat(Union{Function, AVec{Function}}) -all3D(d::KW) = trueOrAllTrue(lt -> lt in (:contour, :heatmap, :surface, :wireframe, :contour3d), get(d, :linetype, :none)) +all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :heatmap, :surface, :wireframe, :contour3d), get(d, :seriestype, :none)) # missing convertToAnyVector(v::@compat(Void), d::KW) = Any[nothing], nothing @@ -142,19 +142,19 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # dumpdict(d, "after getSeriesArgs") # # d[:x], d[:y], d[:z] = compute_xyz(xs[mod1(i,mx)], ys[mod1(i,my)], zs[mod1(i,mz)]) -# lt = d[:linetype] +# st = d[:seriestype] # -# # for linetype `line`, need to sort by x values -# if lt == :line +# # for seriestype `line`, need to sort by x values +# if st == :line # # order by x # indices = sortperm(d[:x]) # d[:x] = d[:x][indices] # d[:y] = d[:y][indices] -# d[:linetype] = :path +# d[:seriestype] = :path # end # # # special handling for missing x in box plot... all the same category -# if lt == :box && xs[mod1(i,mx)] == nothing +# if st == :box && xs[mod1(i,mx)] == nothing # d[:x] = ones(Int, length(d[:y])) # end # @@ -187,22 +187,22 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # # either a series of velocity vectors are passed in (`:quiver` keyword), # # or we just add arrows to the path # -# # if lt == :quiver -# # d[:linetype] = lt = :path +# # if st == :quiver +# # d[:seriestype] = st = :path # # d[:linewidth] = 0 # # end # if get(d, :quiver, nothing) != nothing # append!(ret, apply_series_recipe(copy(d), Val{:quiver})) -# elseif lt == :quiver -# d[:linetype] = lt = :path +# elseif st == :quiver +# d[:seriestype] = st = :path # d[:arrow] = arrow() # end # # # now that we've processed a given series... optionally split into # # multiple dicts through a recipe (for example, a box plot is split into component # # parts... polygons, lines, and scatters) -# # note: we pass in a Val type (i.e. Val{:box}) so that we can dispatch on the linetype -# kwlist = apply_series_recipe(d, Val{lt}) +# # note: we pass in a Val type (i.e. Val{:box}) so that we can dispatch on the seriestype +# kwlist = apply_series_recipe(d, Val{st}) # append!(ret, kwlist) # # # # add it to our series list @@ -254,12 +254,12 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # # # images - grays # function process_inputs{T<:Gray}(plt::AbstractPlot, d::KW, mat::AMat{T}) -# d[:linetype] = :image +# d[:seriestype] = :image # n,m = size(mat) # d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat) # # handle images... when not supported natively, do a hack to use heatmap machinery # if !nativeImagesSupported() -# d[:linetype] = :heatmap +# d[:seriestype] = :heatmap # d[:yflip] = true # d[:z] = Surface(convert(Matrix{Float64}, mat.surf)) # d[:fillcolor] = ColorGradient([:black, :white]) @@ -268,7 +268,7 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # # # images - colors # function process_inputs{T<:Colorant}(plt::AbstractPlot, d::KW, mat::AMat{T}) -# d[:linetype] = :image +# d[:seriestype] = :image # n,m = size(mat) # d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat) # # handle images... when not supported natively, do a hack to use heatmap machinery @@ -282,11 +282,11 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # # plotting arbitrary shapes/polygons # function process_inputs(plt::AbstractPlot, d::KW, shape::Shape) # d[:x], d[:y] = shape_coords(shape) -# d[:linetype] = :shape +# d[:seriestype] = :shape # end # function process_inputs(plt::AbstractPlot, d::KW, shapes::AVec{Shape}) # d[:x], d[:y] = shape_coords(shapes) -# d[:linetype] = :shape +# d[:seriestype] = :shape # end # function process_inputs(plt::AbstractPlot, d::KW, shapes::AMat{Shape}) # x, y = [], [] @@ -296,7 +296,7 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # push!(y, tmpy) # end # d[:x], d[:y] = x, y -# d[:linetype] = :shape +# d[:seriestype] = :shape # end # # @@ -331,12 +331,12 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # # # 3d line or scatter # function process_inputs(plt::AbstractPlot, d::KW, x::AVec, y::AVec, zvec::AVec) -# # default to path3d if we haven't set a 3d linetype -# lt = get(d, :linetype, :none) -# if lt == :scatter -# d[:linetype] = :scatter3d -# elseif !(lt in _3dTypes) -# d[:linetype] = :path3d +# # default to path3d if we haven't set a 3d seriestype +# st = get(d, :seriestype, :none) +# if st == :scatter +# d[:seriestype] = :scatter3d +# elseif !(st in _3dTypes) +# d[:seriestype] = :path3d # end # d[:x], d[:y], d[:z] = x, y, zvec # end @@ -362,8 +362,8 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # # y, zmat = y[idx], zmat[:, idx] # # end # d[:x], d[:y], d[:z] = x, y, Surface{Matrix{TZ}}(zmat) -# if !like_surface(get(d, :linetype, :none)) -# d[:linetype] = :contour +# if !like_surface(get(d, :seriestype, :none)) +# d[:seriestype] = :contour # end # end # @@ -372,8 +372,8 @@ compute_xyz(x::Void, y::Void, z::Void) = error("x/y/z are all nothing!") # @assert size(zmat) == size(x) == size(y) # # d[:x], d[:y], d[:z] = Any[x], Any[y], Surface{Matrix{Float64}}(zmat) # d[:x], d[:y], d[:z] = map(Surface{Matrix{Float64}}, (x, y, zmat)) -# if !like_surface(get(d, :linetype, :none)) -# d[:linetype] = :contour +# if !like_surface(get(d, :seriestype, :none)) +# d[:seriestype] = :contour # end # end # diff --git a/src/series_new.jl b/src/series_new.jl index 9fabe90f..bf032cad 100644 --- a/src/series_new.jl +++ b/src/series_new.jl @@ -25,8 +25,8 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int) # end # end - # if haskey(_typeAliases, d[:linetype]) - # d[:linetype] = _typeAliases[d[:linetype]] + # if haskey(_typeAliases, d[:seriestype]) + # d[:seriestype] = _typeAliases[d[:seriestype]] # end aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex) @@ -39,7 +39,7 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int) # update colors for csym in (:linecolor, :markercolor, :fillcolor) d[csym] = if d[csym] == :match - if has_black_border_for_default(d[:linetype]) && csym == :linecolor + if has_black_border_for_default(d[:seriestype]) && csym == :linecolor :black else d[:seriescolor] @@ -62,7 +62,7 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int) end # scatter plots don't have a line, but must have a shape - if d[:linetype] in (:scatter, :scatter3d) + if d[:seriestype] in (:scatter, :scatter3d) d[:linewidth] = 0 if d[:markershape] == :none d[:markershape] = :ellipse @@ -171,12 +171,12 @@ end # # # images - grays # function process_inputs{T<:Gray}(plt::AbstractPlot, d::KW, mat::AMat{T}) -# d[:linetype] = :image +# d[:seriestype] = :image # n,m = size(mat) # d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat) # # handle images... when not supported natively, do a hack to use heatmap machinery # if !nativeImagesSupported() -# d[:linetype] = :heatmap +# d[:seriestype] = :heatmap # d[:yflip] = true # d[:z] = Surface(convert(Matrix{Float64}, mat.surf)) # d[:fillcolor] = ColorGradient([:black, :white]) @@ -185,11 +185,11 @@ end @recipe function f{T<:Gray}(mat::AMat{T}) if nativeImagesSupported() - linetype --> :image, force + seriestype --> :image, force n, m = size(mat) 1:n, 1:m, Surface(mat) else - linetype --> :heatmap, force + seriestype --> :heatmap, force yflip --> true fillcolor --> ColorGradient([:black, :white]) 1:n, 1:m, Surface(convert(Matrix{Float64}, mat)) @@ -199,7 +199,7 @@ end # # # images - colors # function process_inputs{T<:Colorant}(plt::AbstractPlot, d::KW, mat::AMat{T}) -# d[:linetype] = :image +# d[:seriestype] = :image # n,m = size(mat) # d[:x], d[:y], d[:z] = 1:n, 1:m, Surface(mat) # # handle images... when not supported natively, do a hack to use heatmap machinery @@ -212,11 +212,11 @@ end @recipe function f{T<:Colorant}(mat::AMat{T}) if nativeImagesSupported() - linetype --> :image, force + seriestype --> :image, force n, m = size(mat) 1:n, 1:m, Surface(mat) else - linetype --> :heatmap, force + seriestype --> :heatmap, force yflip --> true z, d[:fillcolor] = replace_image_with_heatmap(mat) 1:n, 1:m, Surface(z) @@ -227,21 +227,21 @@ end # # plotting arbitrary shapes/polygons # function process_inputs(plt::AbstractPlot, d::KW, shape::Shape) # d[:x], d[:y] = shape_coords(shape) -# d[:linetype] = :shape +# d[:seriestype] = :shape # end @recipe function f(shape::Shape) - linetype --> :shape, force + seriestype --> :shape, force shape_coords(shape) end # function process_inputs(plt::AbstractPlot, d::KW, shapes::AVec{Shape}) # d[:x], d[:y] = shape_coords(shapes) -# d[:linetype] = :shape +# d[:seriestype] = :shape # end @recipe function f(shapes::AVec{Shape}) - linetype --> :shape, force + seriestype --> :shape, force shape_coords(shapes) end @@ -253,7 +253,7 @@ end # push!(y, tmpy) # end # d[:x], d[:y] = x, y -# d[:linetype] = :shape +# d[:seriestype] = :shape # end @recipe function f(shapes::AMat{Shape}) @@ -301,22 +301,22 @@ end # # # 3d line or scatter # function process_inputs(plt::AbstractPlot, d::KW, x::AVec, y::AVec, zvec::AVec) -# # default to path3d if we haven't set a 3d linetype -# lt = get(d, :linetype, :none) -# if lt == :scatter -# d[:linetype] = :scatter3d -# elseif !(lt in _3dTypes) -# d[:linetype] = :path3d +# # default to path3d if we haven't set a 3d seriestype +# st = get(d, :seriestype, :none) +# if st == :scatter +# d[:seriestype] = :scatter3d +# elseif !(st in _3dTypes) +# d[:seriestype] = :path3d # end # d[:x], d[:y], d[:z] = x, y, zvec # end @recipe function f(x::AVec, y::AVec, z::AVec) - lt = get(d, :linetype, :none) - if lt == :scatter - d[:linetype] = :scatter3d - elseif !(lt in _3dTypes) - d[:linetype] = :path3d + st = get(d, :seriestype, :none) + if st == :scatter + d[:seriestype] = :scatter3d + elseif !(st in _3dTypes) + d[:seriestype] = :path3d end SliceIt, x, y, z end @@ -350,14 +350,14 @@ end # # y, zmat = y[idx], zmat[:, idx] # # end # d[:x], d[:y], d[:z] = x, y, Surface{Matrix{TZ}}(zmat) -# if !like_surface(get(d, :linetype, :none)) -# d[:linetype] = :contour +# if !like_surface(get(d, :seriestype, :none)) +# d[:seriestype] = :contour # end # end @recipe function f{X,Y,Z}(x::AVec{X}, y::AVec{Y}, z::AMat{Z}) - if !like_surface(get(d, :linetype, :none)) - d[:linetype] = :contour + if !like_surface(get(d, :seriestype, :none)) + d[:seriestype] = :contour end SliceIt, x, y, Surface{Matrix{Z}}(z) end @@ -368,8 +368,8 @@ end # @assert size(zmat) == size(x) == size(y) # # d[:x], d[:y], d[:z] = Any[x], Any[y], Surface{Matrix{Float64}}(zmat) # d[:x], d[:y], d[:z] = map(Surface{Matrix{Float64}}, (x, y, zmat)) -# if !like_surface(get(d, :linetype, :none)) -# d[:linetype] = :contour +# if !like_surface(get(d, :seriestype, :none)) +# d[:seriestype] = :contour # end # end diff --git a/src/utils.jl b/src/utils.jl index 59fa6810..e99187c6 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -25,7 +25,7 @@ function histogramHack(; kw...) edges, midpoints, buckets, counts = binData(d[:y], d[:bins]) d[:x] = midpoints d[:y] = float(counts) - d[:linetype] = :bar + d[:seriestype] = :bar d[:fillrange] = d[:fillrange] == nothing ? 0.0 : d[:fillrange] d end @@ -64,7 +64,7 @@ function barHack(; kw...) d[:x] = x d[:y] = y - d[:linetype] = :path + d[:seriestype] = :path d[:fillrange] = fillrange d end @@ -94,12 +94,12 @@ function sticksHack(; kw...) # change the line args dLine[:x] = x dLine[:y] = y - dLine[:linetype] = :path + dLine[:seriestype] = :path dLine[:markershape] = :none dLine[:fillrange] = nothing # change the scatter args - dScatter[:linetype] = :none + dScatter[:seriestype] = :none dLine, dScatter end @@ -132,7 +132,7 @@ end function imageHack(d::KW) :heatmap in supportedTypes() || error("Neither :image or :heatmap are supported!") - d[:linetype] = :heatmap + d[:seriestype] = :heatmap d[:z], d[:fillcolor] = replace_image_with_heatmap(d[:z].surf) end # --------------------------------------------------------------- @@ -369,7 +369,7 @@ function with(f::Function, args...; kw...) # # as in: with(:gadfly, :scatter, :legend, :grid) do; ...; end # # TODO: can we generalize this enough to also do something similar in the plot commands?? - # k = :linetype + # k = :seriestype # if arg in _allTypes # olddefs[k] = default(k) # newdefs[k] = arg