From da25f973fbab216498cdb0c96268e43b9778b76d Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Wed, 2 Nov 2022 17:17:14 +0100 Subject: [PATCH] rename yfill -> fill --- NEWS.md | 4 +- RecipesPipeline/src/series_recipe.jl | 2 +- src/arg_desc.jl | 8 ++-- src/args.jl | 48 +++++++++++------------- src/axes.jl | 4 +- src/backends.jl | 46 +++++++++++------------ src/backends/deprecated/pgfplots.jl | 10 ++--- src/backends/gaston.jl | 4 +- src/backends/gr.jl | 22 +++++------ src/backends/inspectdr.jl | 2 +- src/backends/pgfplotsx.jl | 4 +- src/backends/plotly.jl | 56 ++++++++++++++-------------- src/backends/pyplot.jl | 20 +++++----- src/pipeline.jl | 6 +-- src/recipes.jl | 30 +++++++-------- src/unitful.jl | 2 +- src/utils.jl | 22 +++++------ test/test_defaults.jl | 4 +- test/test_misc.jl | 6 +-- 19 files changed, 148 insertions(+), 152 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8e8d79d40..8eb76b21e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -590,7 +590,7 @@ Many updates, min julia 1.0 - allow calling `plot!(sp, ...)` to update a target Subplot - PyPlot: zorder fix - new DataFrames logic/recipe: more flexible/robust and allow Symbols for: - - `(:fillrange, :line_z, :marker_z, :marker_size, :ribbon, :weights, :xerror, :yerror)` + - `(:yfill_range, :line_z, :marker_z, :marker_size, :ribbon, :weights, :xerror, :yerror)` - new `display_type` and `extra_kwargs` plot attributes - surface fix @@ -808,7 +808,7 @@ Many updates, min julia 1.0 - New dependency on Requires, allows auto-loading of DataFrames support - Support for plotting lists of Tuples and FixedSizeArrays - new `@animate` macro for super simple animations (see https://github.com/tbreloff/Plots.jl/issues/111#issuecomment-181515616) -- allow Function for `:fillrange` and `zcolor` arguments (for example: `scatter(sin, 0:10, marker=15, fill=(cos,0.4), zcolor=sin)`) +- allow Function for `:yfill_range` and `zcolor` arguments (for example: `scatter(sin, 0:10, marker=15, fill=(cos,0.4), zcolor=sin)`) - allow vectors of PlotText without x/y coords (for example: `scatter(rand(10), m=20, ann=map(text, 1:10))`) - Lots and lots of fixes diff --git a/RecipesPipeline/src/series_recipe.jl b/RecipesPipeline/src/series_recipe.jl index bb4275803..8f8cdc9bc 100644 --- a/RecipesPipeline/src/series_recipe.jl +++ b/RecipesPipeline/src/series_recipe.jl @@ -37,7 +37,7 @@ function _process_seriesrecipe(plt, plotattributes) # shapes shouldn't have fillrange set if plotattributes[:seriestype] == :shape - plotattributes[:fillrange] = nothing + plotattributes[:yfill_range] = nothing end # if it's natively supported, finalize processing and pass along to the backend, diff --git a/src/arg_desc.jl b/src/arg_desc.jl index f85d02d2d..a62cba8f6 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -10,11 +10,11 @@ const _arg_desc = KW( :line_width => "Number. Width of the line (in pixels)", :line_color => "Color Type. Color of the line (for path and bar stroke). `:match` will take the value from `:seriescolor`, (though histogram/bar types use `:black` as a default).", :line_alpha => "Number in [0,1]. The alpha/opacity override for the line. `nothing` (the default) means it will take the alpha value of linecolor.", - :fillrange => "Number or AbstractVector. Fills area between fillrange and y for line-types, sets the base for bar/stick types, and similar for other types.", - :fillcolor => "Color Type. Color of the filled area of path or bar types. `:match` will take the value from `:seriescolor`.", - :fillalpha => "Number in [0,1]. The alpha/opacity override for the fill area. `nothing` (the default) means it will take the alpha value of fillcolor.", + :yfill_range => "Number or AbstractVector. Fills area between fillrange and y for line-types, sets the base for bar/stick types, and similar for other types.", + :yfill_color => "Color Type. Color of the filled area of path or bar types. `:match` will take the value from `:seriescolor`.", + :yfill_alpha => "Number in [0,1]. The alpha/opacity override for the fill area. `nothing` (the default) means it will take the alpha value of fillcolor.", :marker_shape => "Symbol, Shape, or AbstractVector. Choose from $(_allMarkers).", - :fillstyle => "Symbol. Style of the fill area. `nothing` (the default) means solid fill. Choose from :/, :\\, :|, :-, :+, :x", + :yfill_style => "Symbol. Style of the fill area. `nothing` (the default) means solid fill. Choose from :/, :\\, :|, :-, :+, :x", :marker_color => "Color Type. Color of the interior of the marker or shape. `:match` will take the value from `:seriescolor`.", :marker_alpha => "Number in [0,1]. The alpha/opacity override for the marker interior. `nothing` (the default) means it will take the alpha value of markercolor.", :marker_size => "Number or AbstractVector. Size (radius pixels) of the markers", diff --git a/src/args.jl b/src/args.jl index 9bb15f30d..14acf2b99 100644 --- a/src/args.jl +++ b/src/args.jl @@ -325,10 +325,6 @@ const _series_defaults = KW( :seriescolor => :auto, :seriesalpha => nothing, :seriestype => :path, - :fillrange => nothing, # ribbons, areas, etc - :fillcolor => :match, - :fillalpha => nothing, - :fillstyle => nothing, :bins => :auto, # number of bins for hists :smooth => false, # regression line? :group => nothing, # groupby vector @@ -600,7 +596,7 @@ add_aliases(:line_color, :lc, :lcolor, :lcolour, :linecolour) add_aliases(:marker_color, :mc, :mcolor, :mcolour, :markercolour) add_aliases(:marker_stroke_color, :msc, :mscolor, :mscolour, :markerstrokecolour) add_aliases(:marker_stroke_width, :msw, :mswidth) -add_aliases(:fillcolor, :fc, :fcolor, :fcolour, :fillcolour) +add_aliases(:yfill_color, :fc, :fcolor, :fcolour, :fillcolour) add_aliases( :background_color, @@ -818,7 +814,7 @@ add_aliases(:seriesalpha, :alpha, :α, :opacity) add_aliases(:line_alpha, :la, :lalpha, :lα, :lineopacity, :lopacity) add_aliases(:marker_alpha, :ma, :malpha, :mα, :markeropacity, :mopacity) add_aliases(:marker_stroke_alpha, :msa, :msalpha, :msα, :markerstrokeopacity, :msopacity) -add_aliases(:fillalpha, :fa, :falpha, :fα, :fillopacity, :fopacity) +add_aliases(:yfill_alpha, :fa, :falpha, :fα, :fillopacity, :fopacity) # axes attributes add_axes_aliases(:guide, :label, :lab, :l; generic = false) @@ -906,7 +902,7 @@ add_aliases(:marker_size, :ms, :msize) add_aliases(:marker_z, :markerz, :zcolor, :mz) add_aliases(:line_z, :linez, :zline, :lz) add_aliases(:fill, :f, :area) -add_aliases(:fillrange, :fillrng, :frange, :fillto, :fill_between) +add_aliases(:yfill_range, :fillrng, :frange, :fillto, :fill_between) add_aliases(:group, :g, :grouping) add_aliases(:bins, :bin, :nbin, :nbins, :nb) add_aliases(:ribbon, :rib) @@ -1121,13 +1117,13 @@ function processLineArg(plotattributes::AKW, arg) arg.style === nothing || (plotattributes[:line_style] = arg.style) elseif typeof(arg) <: Brush - arg.size === nothing || (plotattributes[:fillrange] = arg.size) + arg.size === nothing || (plotattributes[:yfill_range] = arg.size) arg.color === nothing || ( - plotattributes[:fillcolor] = + plotattributes[:yfill_color] = arg.color === :auto ? :auto : plot_color(arg.color) ) - arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha) - arg.style === nothing || (plotattributes[:fillstyle] = arg.style) + arg.alpha === nothing || (plotattributes[:yfill_alpha] = arg.alpha) + arg.style === nothing || (plotattributes[:yfill_style] = arg.style) elseif typeof(arg) <: Arrow || arg in (:arrow, :arrows) plotattributes[:arrow] = arg @@ -1191,35 +1187,35 @@ function processMarkerArg(plotattributes::AKW, arg) end function processFillArg(plotattributes::AKW, arg) - # fr = get(plotattributes, :fillrange, 0) + # fr = get(plotattributes, :yfill_range, 0) if typeof(arg) <: Brush - arg.size === nothing || (plotattributes[:fillrange] = arg.size) + arg.size === nothing || (plotattributes[:yfill_range] = arg.size) arg.color === nothing || ( - plotattributes[:fillcolor] = + plotattributes[:yfill_color] = arg.color === :auto ? :auto : plot_color(arg.color) ) - arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha) - arg.style === nothing || (plotattributes[:fillstyle] = arg.style) + arg.alpha === nothing || (plotattributes[:yfill_alpha] = arg.alpha) + arg.style === nothing || (plotattributes[:yfill_style] = arg.style) elseif typeof(arg) <: Bool - plotattributes[:fillrange] = arg ? 0 : nothing + plotattributes[:yfill_range] = arg ? 0 : nothing # fillrange function elseif allFunctions(arg) - plotattributes[:fillrange] = arg + plotattributes[:yfill_range] = arg # fillalpha elseif allAlphas(arg) - plotattributes[:fillalpha] = arg + plotattributes[:yfill_alpha] = arg # fillrange provided as vector or number elseif typeof(arg) <: Union{AbstractArray{<:Real},Real} - plotattributes[:fillrange] = arg + plotattributes[:yfill_range] = arg - elseif !handleColors!(plotattributes, arg, :fillcolor) - plotattributes[:fillrange] = arg + elseif !handleColors!(plotattributes, arg, :yfill_color) + plotattributes[:yfill_range] = arg end - # plotattributes[:fillrange] = fr + # plotattributes[:yfill_range] = fr nothing end @@ -2084,7 +2080,7 @@ function _update_series_attributes!(plotattributes::AKW, plt::Plot, sp::Subplot) ) # update alphas - for asym in (:line_alpha, :marker_alpha, :fillalpha) + for asym in (:line_alpha, :marker_alpha, :yfill_alpha) if plotattributes[asym] === nothing plotattributes[asym] = plotattributes[:seriesalpha] end @@ -2099,7 +2095,7 @@ function _update_series_attributes!(plotattributes::AKW, plt::Plot, sp::Subplot) plotattributes[:seriescolor] = scolor = get_series_color(scolor, sp, plotIndex, stype) # update other colors - for s in (:line_, :marker_, :fill) + for s in (:line_, :marker_, :yfill_) csym, asym = Symbol(s, :color), Symbol(s, :alpha) plotattributes[csym] = if plotattributes[csym] === :auto plot_color(if has_black_border_for_default(stype) && s === :line @@ -2131,7 +2127,7 @@ function _update_series_attributes!(plotattributes::AKW, plt::Plot, sp::Subplot) ensure_gradient!(plotattributes, :line_color, :line_alpha) end if plotattributes[:fill_z] !== nothing - ensure_gradient!(plotattributes, :fillcolor, :fillalpha) + ensure_gradient!(plotattributes, :yfill_color, :yfill_alpha) end # scatter plots don't have a line, but must have a shape diff --git a/src/axes.jl b/src/axes.jl index 79c1949d0..19d8cd946 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -455,7 +455,7 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW) # end # expand for fillrange - fr = plotattributes[:fillrange] + fr = plotattributes[:yfill_range] if fr === nothing && plotattributes[:seriestype] === :bar fr = 0.0 end @@ -514,7 +514,7 @@ end scale_lims!([plt], [letter], factor) Scale the limits of the axis specified by `letter` (one of `:x`, `:y`, `:z`) by the -given `factor` around the limits' middle point. +given `factor` around the limits' middle point. If `letter` is omitted, all axes are affected. """ function scale_lims!(sp::Subplot, letter, factor) diff --git a/src/backends.jl b/src/backends.jl index 71cd5b129..4bccaf0ba 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -315,10 +315,10 @@ const _gr_attr = merge_with_base_supported([ :marker_stroke_width, :marker_stroke_color, :marker_stroke_alpha, - :fillrange, - :fillcolor, - :fillalpha, - :fillstyle, + :yfill_range, + :yfill_color, + :yfill_alpha, + :yfill_style, :bins, :layout, :title, @@ -448,9 +448,9 @@ const _plotly_attr = merge_with_base_supported([ :marker_stroke_color, :marker_stroke_alpha, :marker_stroke_style, - :fillrange, - :fillcolor, - :fillalpha, + :yfill_range, + :yfill_color, + :yfill_alpha, :bins, :title, :titlelocation, @@ -573,9 +573,9 @@ const _pgfplots_attr = merge_with_base_supported([ :marker_stroke_color, :marker_stroke_alpha, :marker_stroke_style, - :fillrange, - :fillcolor, - :fillalpha, + :yfill_range, + :yfill_color, + :yfill_alpha, :bins, # :bar_width, :bar_edges, :title, @@ -687,10 +687,10 @@ const _pyplot_attr = merge_with_base_supported([ :marker_stroke_width, :marker_stroke_color, :marker_stroke_alpha, - :fillrange, - :fillcolor, - :fillalpha, - :fillstyle, + :yfill_range, + :yfill_color, + :yfill_alpha, + :yfill_style, :bins, :bar_width, :bar_edges, @@ -806,7 +806,7 @@ const _gaston_attr = merge_with_base_supported([ :marker_size, :marker_alpha, # :marker_stroke_width, :marker_stroke_color, :marker_stroke_alpha, :marker_stroke_style, - # :fillrange, :fillcolor, :fillalpha, + # :yfill_range, :yfill_color, :yfill_alpha, # :bins, # :bar_width, :bar_edges, :title, @@ -988,9 +988,9 @@ const _hdf5_attr = merge_with_base_supported([ :marker_stroke_width, :marker_stroke_color, :marker_stroke_alpha, - :fillrange, - :fillcolor, - :fillalpha, + :yfill_range, + :yfill_color, + :yfill_alpha, :bins, :bar_width, :bar_edges, @@ -1094,8 +1094,8 @@ const _inspectdr_attr = merge_with_base_supported([ :marker_stroke_color, :marker_stroke_alpha, :marker_stroke_style, #Causes warning not to have it... what is this? - :fillcolor, - :fillalpha, #:fillrange, + :yfill_color, + :yfill_alpha, #:yfill_range, # :bins, :bar_width, :bar_edges, :bar_position, :title, :titlelocation, @@ -1195,9 +1195,9 @@ const _pgfplotsx_attr = merge_with_base_supported([ :marker_stroke_width, :marker_stroke_color, :marker_stroke_alpha, - :fillrange, - :fillcolor, - :fillalpha, + :yfill_range, + :yfill_color, + :yfill_alpha, :bins, :layout, :title, diff --git a/src/backends/deprecated/pgfplots.jl b/src/backends/deprecated/pgfplots.jl index 780ecf748..2c241a63a 100644 --- a/src/backends/deprecated/pgfplots.jl +++ b/src/backends/deprecated/pgfplots.jl @@ -225,12 +225,12 @@ function pgf_series(sp::Subplot, series::Series) # add to legend? if i == 1 && sp[:legend_position] !== :none && should_add_to_legend(series) - if plotattributes[:fillrange] !== nothing + if plotattributes[:yfill_range] !== nothing push!(style, "forget plot") push!(series_collection, pgf_fill_legend_hack(plotattributes, args)) else kw[:legendentry] = plotattributes[:label] - if st === :shape # || plotattributes[:fillrange] !== nothing + if st === :shape # || plotattributes[:yfill_range] !== nothing push!(style, "area legend") end end @@ -247,13 +247,13 @@ function pgf_series(sp::Subplot, series::Series) kw[:style] = join(style, ',') # add fillrange - if series[:fillrange] !== nothing && st !== :shape + if series[:yfill_range] !== nothing && st !== :shape push!( series_collection, pgf_fillrange_series( series, i, - _cycle(series[:fillrange], rng), + _cycle(series[:yfill_range], rng), seg_args..., ), ) @@ -641,7 +641,7 @@ function _update_plot_object(plt::Plot{PGFPlotsBackend}) # As it is likely that all series within the same axis use the same # colormap this should not cause any problem. for series in series_list(sp) - for col in (:marker_color, :fillcolor, :line_color) + for col in (:marker_color, :yfill_color, :line_color) if typeof(series.plotattributes[col]) == ColorGradient push!( style, diff --git a/src/backends/gaston.jl b/src/backends/gaston.jl index 04e41c9f7..eb4e5a934 100644 --- a/src/backends/gaston.jl +++ b/src/backends/gaston.jl @@ -222,7 +222,7 @@ function gaston_add_series(plt::Plot{GastonBackend}, series::Series) if gsp.dims == 2 && z === nothing for (n, seg) in enumerate(series_segments(series, st; check = true)) i, rng = seg.attr_index, seg.range - fr = _cycle(series[:fillrange], 1:length(x[rng])) + fr = _cycle(series[:yfill_range], 1:length(x[rng])) for sc in gaston_seriesconf!(sp, series, i, n == 1) push!(curves, Gaston.Curve(x[rng], y[rng], nothing, fr, sc)) end @@ -296,7 +296,7 @@ function gaston_seriesconf!( pt, ps, mc = gaston_mk_ms_mc(series, clims, i) push!(curveconf, "w points pt $pt ps $ps lc $mc") elseif st ∈ (:path, :straightline, :path3d) - fr = series[:fillrange] + fr = series[:yfill_range] fc = gaston_color(get_fillcolor(series, i), get_fillalpha(series, i)) fs = get_fillstyle(series, i) # FIXME: add fillstyle support ? lc, dt, lw = gaston_lc_ls_lw(series, clims, i) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index ffd38265b..ec99fa4ff 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1008,7 +1008,7 @@ function gr_add_legend(sp, leg, viewport_area) 0.5leg.width_factor, 3.5leg.width_factor, 0.4leg.dy, 0.4leg.dy if ( - (st === :shape || series[:fillrange] !== nothing) && + (st === :shape || series[:yfill_range] !== nothing) && series[:ribbon] === nothing ) (fc = get_fillcolor(series, clims)) |> gr_set_fill @@ -1033,7 +1033,7 @@ function gr_add_legend(sp, leg, viewport_area) # 1 / leg.dy translates width_factor to line length units (important in the context of size kwarg) # gr_legend_marker_to_line_factor is an empirical constant to translate between line length unit and marker size unit maxmarkersize = gr_legend_marker_to_line_factor[] * 0.5(rgt - lft) / leg.dy - if series[:fillrange] === nothing || series[:ribbon] !== nothing + if series[:yfill_range] === nothing || series[:ribbon] !== nothing GR.polyline([xpos - rgt, xpos - lft], [ypos, ypos]) else GR.polyline([xpos - rgt, xpos - lft], [ypos + bot, ypos + top]) @@ -1611,7 +1611,7 @@ function gr_add_series(sp, series) x, y, z = map(letter -> handle_surface(series[letter]), (:x, :y, :z)) xscale, yscale = sp[:xaxis][:scale], sp[:yaxis][:scale] - frng = series[:fillrange] + frng = series[:yfill_range] # recompute data if ispolar(sp) && z === nothing @@ -1791,7 +1791,7 @@ function gr_draw_contour(series, x, y, z, clims) gr_set_line(get_linewidth(series), get_linestyle(series), get_line_color(series), series) gr_set_transparency(get_fillalpha(series)) h = gr_contour_levels(series, clims) - if series[:fillrange] !== nothing + if series[:yfill_range] !== nothing GR.contourf(x, y, h, z, series[:contour_labels] == true ? 1 : 0) else black = plot_color(:black) @@ -1847,10 +1847,10 @@ function gr_draw_surface(series, x, y, z, clims) ArgumentError |> throw end - facecolor = if series[:fillcolor] isa AbstractArray - series[:fillcolor] + facecolor = if series[:yfill_color] isa AbstractArray + series[:yfill_color] else - fill(series[:fillcolor], length(cns)) + fill(series[:yfill_color], length(cns)) end fillalpha = get_fillalpha(series) facecolor = map(fc -> set_RGBA_alpha(fillalpha, fc), facecolor) @@ -1864,7 +1864,7 @@ function gr_draw_surface(series, x, y, z, clims) end function gr_draw_heatmap(series, x, y, z, clims) - fillgrad = _as_gradient(series[:fillcolor]) + fillgrad = _as_gradient(series[:yfill_color]) GR.setprojectiontype(0) GR.setspace(clims..., 0, 90) w, h = length(x) - 1, length(y) - 1 @@ -1876,18 +1876,18 @@ function gr_draw_heatmap(series, x, y, z, clims) # Note that drawimage draws uniformly spaced data correctly # even on log scales, where it is visually non-uniform. colors, _z = if sp[:colorbar_scale] === :identity - plot_color.(get(fillgrad, z, clims), series[:fillalpha]), z + plot_color.(get(fillgrad, z, clims), series[:yfill_alpha]), z elseif sp[:colorbar_scale] === :log10 z_log = replace(x -> isinf(x) ? NaN : x, log10.(z)) z_normalized = get_z_normalized.(z_log, log10.(clims)...) - plot_color.(map(z -> get(fillgrad, z), z_normalized), series[:fillalpha]), z_log + plot_color.(map(z -> get(fillgrad, z), z_normalized), series[:yfill_alpha]), z_log end for i in eachindex(colors) isnan(_z[i]) && (colors[i] = set_RGBA_alpha(0, colors[i])) end GR.drawimage(first(x), last(x), last(y), first(y), w, h, gr_color.(colors)) else - if something(series[:fillalpha], 1) < 1 + if something(series[:yfill_alpha], 1) < 1 @warn "GR: transparency not supported in non-uniform heatmaps. Alpha values ignored." end z_normalized, _z = if sp[:colorbar_scale] === :identity diff --git a/src/backends/inspectdr.jl b/src/backends/inspectdr.jl index 1fa096f82..61af8a7fe 100644 --- a/src/backends/inspectdr.jl +++ b/src/backends/inspectdr.jl @@ -240,7 +240,7 @@ function _series_added(plt::Plot{InspectDRBackend}, series::Series) end #= TODO: Eventually support - series[:fillcolor] #I think this is fill under line + series[:yfill_color] #I think this is fill under line zorder = series[:series_plotindex] For st in :shape: diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index fcf95085f..c04fd5f70 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -283,7 +283,7 @@ function (pgfx_plot::PGFPlotsXPlot)(plt::Plot{PGFPlotsXBackend}) PGFPlotsX.Plot end if ( - series[:fillrange] !== nothing && + series[:yfill_range] !== nothing && series[:ribbon] === nothing && !isfilledcontour(series) ) @@ -359,7 +359,7 @@ function pgfx_add_series!(::Val{:path}, axis, series_opt, series, series_func, o segment_opt = merge(segment_opt, pgfx_marker(opt, i)) end # add fillrange - if (sf = opt[:fillrange]) !== nothing && !isfilledcontour(series) + if (sf = opt[:yfill_range]) !== nothing && !isfilledcontour(series) if sf isa Number || sf isa AVec pgfx_fillrange_series!(axis, series, series_func, i, _cycle(sf, rng), rng) elseif sf isa Tuple && series[:ribbon] !== nothing diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index eff913e5d..dd20dfc7c 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -544,7 +544,7 @@ function plotly_series(plt::Plot, series::Series) hasline = st in (:path, :path3d, :straightline) hasfillrange = st in (:path, :scatter, :scattergl, :straightline) && - (isa(series[:fillrange], AbstractVector) || isa(series[:fillrange], Tuple)) + (isa(series[:yfill_range], AbstractVector) || isa(series[:yfill_range], Tuple)) plotattributes_out[:colorbar] = KW(:title => sp[:colorbar_title]) @@ -562,7 +562,7 @@ function plotly_series(plt::Plot, series::Series) plotattributes_out[:type] = "heatmap" plotattributes_out[:x], plotattributes_out[:y], plotattributes_out[:z] = x, y, z plotattributes_out[:colorscale] = - plotly_colorscale(series[:fillcolor], series[:fillalpha]) + plotly_colorscale(series[:yfill_color], series[:yfill_alpha]) plotattributes_out[:showscale] = hascolorbar(sp) elseif st === :contour @@ -617,8 +617,8 @@ function plotly_series(plt::Plot, series::Series) plotattributes_out[:showscale] = false else plotattributes_out[:colorscale] = - plotly_colorscale(series[:fillcolor], series[:fillalpha]) - plotattributes_out[:opacity] = series[:fillalpha] + plotly_colorscale(series[:yfill_color], series[:yfill_alpha]) + plotattributes_out[:opacity] = series[:yfill_alpha] if series[:fill_z] !== nothing plotattributes_out[:surfacecolor] = handle_surface(series[:fill_z]) end @@ -661,10 +661,10 @@ function plotly_series(plt::Plot, series::Series) end end plotattributes_out[:colorscale] = - plotly_colorscale(series[:fillcolor], series[:fillalpha]) + plotly_colorscale(series[:yfill_color], series[:yfill_alpha]) plotattributes_out[:color] = - rgba_string(plot_color(series[:fillcolor], series[:fillalpha])) - plotattributes_out[:opacity] = series[:fillalpha] + rgba_string(plot_color(series[:yfill_color], series[:yfill_alpha])) + plotattributes_out[:opacity] = series[:yfill_alpha] if series[:fill_z] !== nothing plotattributes_out[:surfacecolor] = handle_surface(series[:fill_z]) end @@ -742,7 +742,7 @@ function plotly_series_shapes(plt::Plot, series::Series, clims) :x => vcat(x[rng], x[rng[1]]), :y => vcat(y[rng], y[rng[1]]), :fill => "tozeroy", - :fillcolor => rgba_string( + :yfill_color => rgba_string( plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)), ), ), @@ -782,7 +782,7 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z hasline = st in (:path, :path3d, :straightline) hasfillrange = st in (:path, :scatter, :scattergl, :straightline) && - (isa(series[:fillrange], AbstractVector) || isa(series[:fillrange], Tuple)) + (isa(series[:yfill_range], AbstractVector) || isa(series[:yfill_range], Tuple)) segments = collect(series_segments(series, st)) plotattributes_outs = fill(KW(), (hasfillrange ? 2 : 1) * length(segments)) @@ -804,20 +804,20 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z else hasline ? "lines" : "none" end - if series[:fillrange] == true || - series[:fillrange] == 0 || - isa(series[:fillrange], Tuple) + if series[:yfill_range] == true || + series[:yfill_range] == 0 || + isa(series[:yfill_range], Tuple) plotattributes_out[:fill] = "tozeroy" - plotattributes_out[:fillcolor] = rgba_string( + plotattributes_out[:yfill_color] = rgba_string( plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)), ) - elseif typeof(series[:fillrange]) <: Union{AbstractVector{<:Real},Real} + elseif typeof(series[:yfill_range]) <: Union{AbstractVector{<:Real},Real} plotattributes_out[:fill] = "tonexty" - plotattributes_out[:fillcolor] = rgba_string( + plotattributes_out[:yfill_color] = rgba_string( plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)), ) - elseif !(series[:fillrange] in (false, nothing)) - @warn "fillrange ignored... plotly only supports filling to zero and to a vector of values. fillrange: $(series[:fillrange])" + elseif !(series[:yfill_range] in (false, nothing)) + @warn "fillrange ignored... plotly only supports filling to zero and to a vector of values. fillrange: $(series[:yfill_range])" end plotattributes_out[:x], plotattributes_out[:y] = x[rng], y[rng] @@ -901,29 +901,29 @@ function plotly_series_segments(series::Series, plotattributes_base::KW, x, y, z plotattributes_out_fillrange = deepcopy(plotattributes_out) plotattributes_out_fillrange[:showlegend] = false # if fillrange is provided as real or tuple of real, expand to array - if typeof(series[:fillrange]) <: Real - plotattributes_out[:fillrange] = fill(series[:fillrange], length(rng)) - elseif typeof(series[:fillrange]) <: Tuple + if typeof(series[:yfill_range]) <: Real + plotattributes_out[:yfill_range] = fill(series[:yfill_range], length(rng)) + elseif typeof(series[:yfill_range]) <: Tuple f1 = - (fr1 = series[:fillrange][1]) |> typeof <: Real ? + (fr1 = series[:yfill_range][1]) |> typeof <: Real ? fill(fr1, length(rng)) : fr1[rng] f2 = - (fr2 = series[:fillrange][2]) |> typeof <: Real ? + (fr2 = series[:yfill_range][2]) |> typeof <: Real ? fill(fr2, length(rng)) : fr2[rng] - plotattributes_out[:fillrange] = (f1, f2) + plotattributes_out[:yfill_range] = (f1, f2) end - if isa(series[:fillrange], AbstractVector) - plotattributes_out_fillrange[:y] = series[:fillrange][rng] + if isa(series[:yfill_range], AbstractVector) + plotattributes_out_fillrange[:y] = series[:yfill_range][rng] delete!(plotattributes_out_fillrange, :fill) - delete!(plotattributes_out_fillrange, :fillcolor) + delete!(plotattributes_out_fillrange, :yfill_color) else # if fillrange is a tuple with upper and lower limit, plotattributes_out_fillrange # is the series that will do the filling plotattributes_out_fillrange[:x], plotattributes_out_fillrange[:y] = - concatenate_fillrange(x[rng], series[:fillrange]) + concatenate_fillrange(x[rng], series[:yfill_range]) plotattributes_out_fillrange[:line][:width] = 0 delete!(plotattributes_out, :fill) - delete!(plotattributes_out, :fillcolor) + delete!(plotattributes_out, :yfill_color) end plotattributes_outs[(2k - 1):(2k)] = diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 154aaa7c6..6156f50e9 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -246,7 +246,7 @@ py_linecolormap(series::Series) = py_markercolormap(series::Series) = py_colormap(cgrad(series[:marker_color], alpha = get_marker_alpha(series))) py_fillcolormap(series::Series) = - py_colormap(cgrad(series[:fillcolor], alpha = get_fillalpha(series))) + py_colormap(cgrad(series[:yfill_color], alpha = get_fillalpha(series))) # --------------------------------------------------------------------------- @@ -537,7 +537,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) C = series[:weights], gridsize = series[:bins] === :auto ? 100 : series[:bins], # 100 is the default value linewidths = py_thickness_scale(plt, series[:line_width]), - alpha = series[:fillalpha], + alpha = series[:yfill_alpha], cmap = py_fillcolormap(series), # applies to the pcolorfast object zorder = series[:series_plotindex], extrakw..., @@ -577,7 +577,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) push!(handles, handle) # contour fills - if series[:fillrange] !== nothing + if series[:yfill_range] !== nothing handle = ax."contourf"( x, y, @@ -585,7 +585,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) levelargs...; label = series[:label], zorder = series[:series_plotindex] + 0.5, - alpha = series[:fillalpha], + alpha = series[:yfill_alpha], extrakw..., ) push!(handles, handle) @@ -601,7 +601,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) if series[:fill_z] !== nothing # the surface colors are different than z-value extrakw[:facecolors] = - py_shading(series[:fillcolor], py_handle_surface(series[:fill_z])) + py_shading(series[:yfill_color], py_handle_surface(series[:fill_z])) extrakw[:shade] = false else extrakw[:cmap] = py_fillcolormap(series) @@ -685,14 +685,14 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) polygons, linewidths = py_thickness_scale(plt, series[:line_width]), edgecolor = py_color(get_line_color(series)), - facecolor = py_color(series[:fillcolor]), + facecolor = py_color(series[:yfill_color]), alpha = get_fillalpha(series), zorder = series[:series_plotindex], ) handle = ax."add_collection3d"(col) # Fix for handle: https://stackoverflow.com/questions/54994600/pyplot-legend-poly3dcollection-object-has-no-attribute-edgecolors2d # It seems there aren't two different alpha values for edge and face - handle._facecolors2d = py_color(series[:fillcolor]) + handle._facecolors2d = py_color(series[:yfill_color]) handle._edgecolors2d = py_color(get_line_color(series)) push!(handles, handle) end @@ -740,7 +740,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) label = series[:label], zorder = series[:series_plotindex], cmap = py_fillcolormap(series), - alpha = series[:fillalpha], + alpha = series[:yfill_alpha], # edgecolors = (series[:line_width] > 0 ? py_linecolor(series) : "face"), extrakw..., ) @@ -802,7 +802,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) # handleSmooth(plt, ax, series, series[:smooth]) # handle area filling - fillrange = series[:fillrange] + fillrange = series[:yfill_range] if fillrange !== nothing && st !== :contour for segment in series_segments(series) i, rng = segment.attr_index, segment.range @@ -1464,7 +1464,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) clims = get_clims(sp, series) # add a line/marker and a label - if series[:seriestype] === :shape || series[:fillrange] !== nothing + if series[:seriestype] === :shape || series[:yfill_range] !== nothing lc = get_line_color(series, clims) fc = get_fillcolor(series, clims) la = get_line_alpha(series) diff --git a/src/pipeline.jl b/src/pipeline.jl index c3c8c5070..42bbb18f1 100644 --- a/src/pipeline.jl +++ b/src/pipeline.jl @@ -127,7 +127,7 @@ function _add_smooth_kw(kw_list::Vector{KW}, kw::AKW) :seriestype => :path, :x => sx, :y => sy, - :fillrange => nothing, + :yfill_range => nothing, :label => "", :primary => false, ), @@ -164,7 +164,7 @@ function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_l for kw in kw_list rib = get(kw, :ribbon, default(:ribbon)) - fr = get(kw, :fillrange, default(:fillrange)) + fr = get(kw, :yfill_range, default(:yfill_range)) # map ribbon if it's a Function if rib isa Function kw[:ribbon] = map(rib, kw[:x]) @@ -174,7 +174,7 @@ function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_l make_fillrange_from_ribbon(kw) # map fillrange if it's a Function elseif fr !== nothing && fr isa Function - kw[:fillrange] = map(fr, kw[:x]) + kw[:yfill_range] = map(fr, kw[:x]) end end nothing diff --git a/src/recipes.jl b/src/recipes.jl index 09d7d2a69..89decf16c 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -51,8 +51,8 @@ const POTENTIAL_VECTOR_ARGUMENTS = [ :line_width, :line_style, :line_z, - :fillcolor, - :fillalpha, + :yfill_color, + :yfill_alpha, :fill_z, :marker_color, :marker_alpha, @@ -64,7 +64,7 @@ const POTENTIAL_VECTOR_ARGUMENTS = [ :yerror, :zerror, :series_annotations, - :fillrange, + :yfill_range, ] @nospecialize @@ -82,11 +82,11 @@ const POTENTIAL_VECTOR_ARGUMENTS = [ end # a tuple as fillrange has to be handled differently - if typeof(plotattributes[:fillrange]) <: Tuple - lower, upper = plotattributes[:fillrange] + if typeof(plotattributes[:yfill_range]) <: Tuple + lower, upper = plotattributes[:yfill_range] typeof(lower) <: AVec && (lower = _cycle(lower, indices)) typeof(upper) <: AVec && (upper = _cycle(upper, indices)) - plotattributes[:fillrange] = (lower, upper) + plotattributes[:yfill_range] = (lower, upper) end typeof(z) <: AVec && (z := z[indices]) @@ -218,7 +218,7 @@ make_steps(t::Tuple, st, even) = Tuple(make_steps(ti, st, even) for ti in t) seriestype := :path # handle fillrange - plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :pre, false) + plotattributes[:yfill_range] = make_steps(plotattributes[:yfill_range], :pre, false) # create a secondary series for the markers if plotattributes[:marker_shape] !== :none @@ -243,7 +243,7 @@ end seriestype := :path # handle fillrange - plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post, true) + plotattributes[:yfill_range] = make_steps(plotattributes[:yfill_range], :post, true) # create a secondary series for the markers if plotattributes[:marker_shape] !== :none @@ -268,7 +268,7 @@ end seriestype := :path # handle fillrange - plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post, false) + plotattributes[:yfill_range] = make_steps(plotattributes[:yfill_range], :post, false) # create a secondary series for the markers if plotattributes[:marker_shape] !== :none @@ -292,7 +292,7 @@ end # create vertical line segments from fill @recipe function f(::Type{Val{:sticks}}, x, y, z) # COV_EXCL_LINE n = length(x) - fr = plotattributes[:fillrange] + fr = plotattributes[:yfill_range] if fr === nothing sp = plotattributes[:subplot] fr = if sp[:yaxis][:scale] === :identity @@ -368,7 +368,7 @@ end @recipe function f(::Type{Val{:curves}}, x, y, z; npoints = 30) # COV_EXCL_LINE args = z !== nothing ? (x, y, z) : (x, y) newx, newy = zeros(0), zeros(0) - fr = plotattributes[:fillrange] + fr = plotattributes[:yfill_range] newfr = fr !== nothing ? zeros(0) : nothing newz = z !== nothing ? zeros(0) : nothing @@ -433,7 +433,7 @@ end end # make fillto a vector... default fills to 0 - if (fillto = plotattributes[:fillrange]) === nothing + if (fillto = plotattributes[:yfill_range]) === nothing fillto = 0 end if yscale in _logScales && !all(_is_positive, fillto) @@ -518,7 +518,7 @@ end y_pts[inds] .= [ye[i], ye[i], ye[i + 1], ye[i + 1], ye[i]] fz[k] = z.surf[i, j] end - ensure_gradient!(plotattributes, :fillcolor, :fillalpha) + ensure_gradient!(plotattributes, :yfill_color, :yfill_alpha) fill_z := fz line_z := fz x := x_pts @@ -1354,7 +1354,7 @@ end yflip --> true colorbar --> false aspect_ratio --> :equal - z, plotattributes[:fillcolor] = replace_image_with_heatmap(mat) + z, plotattributes[:yfill_color] = replace_image_with_heatmap(mat) SliceIt, m, n, Surface(z) end end @@ -1419,7 +1419,7 @@ end seriestype := :heatmap yflip --> true colorbar --> false - z, plotattributes[:fillcolor] = replace_image_with_heatmap(mat) + z, plotattributes[:yfill_color] = replace_image_with_heatmap(mat) SliceIt, x, y, Surface(z) end end diff --git a/src/unitful.jl b/src/unitful.jl index e5552b5d5..1ac542952 100644 --- a/src/unitful.jl +++ b/src/unitful.jl @@ -50,7 +50,7 @@ function fixaxis!(attr, x, axisletter) ustripattribute!(attr, err, u) if axisletter === :y ustripattribute!(attr, :ribbon, u) - ustripattribute!(attr, :fillrange, u) + ustripattribute!(attr, :yfill_range, u) end fixaspectratio!(attr, u, axisletter) fixmarkercolor!(attr) diff --git a/src/utils.jl b/src/utils.jl index f928d9f38..977285218 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -369,8 +369,8 @@ function make_fillrange_from_ribbon(kw::AKW) rib = wraptuple(rib) rib1, rib2 = -first(rib), last(rib) # kw[:ribbon] = nothing - kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2) - (get(kw, :fillalpha, nothing) === nothing) && (kw[:fillalpha] = 0.5) + kw[:yfill_range] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2) + (get(kw, :yfill_alpha, nothing) === nothing) && (kw[:yfill_alpha] = 0.5) end #turn tuple of fillranges to one path @@ -410,7 +410,7 @@ ylims(sp_idx::Int = 1) = ylims(current(), sp_idx) zlims(sp_idx::Int = 1) = zlims(current(), sp_idx) iscontour(series::Series) = series[:seriestype] in (:contour, :contour3d) -isfilledcontour(series::Series) = iscontour(series) && series[:fillrange] !== nothing +isfilledcontour(series::Series) = iscontour(series) && series[:yfill_range] !== nothing function contour_levels(series::Series, clims) iscontour(series) || error("Not a contour series") @@ -423,7 +423,7 @@ function contour_levels(series::Series, clims) levels end -for comp in (:line_, :fill, :marker_) +for comp in (:line_, :yfill_, :marker_) compcolor = string(comp, :color) get_compcolor = Symbol(:get_, compcolor) comp_z = string(comp, :z) @@ -433,7 +433,7 @@ for comp in (:line_, :fill, :marker_) @eval begin function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1) - c = series[$Symbol($compcolor)] # series[:line_color], series[:fillcolor], series[:marker_color] + c = series[$Symbol($compcolor)] # series[:line_color], series[:yfill_color], series[:marker_color] z = series[$Symbol($comp_z)] # series[:line_z], series[:fill_z], series[:marker_z] if z === nothing isa(c, ColorGradient) ? c : plot_color(_cycle(c, i)) @@ -460,7 +460,7 @@ end function get_colorgradient(series::Series) st = series[:seriestype] if st in (:surface, :heatmap) || isfilledcontour(series) - series[:fillcolor] + series[:yfill_color] elseif st in (:contour, :wireframe) series[:line_color] elseif series[:marker_z] !== nothing @@ -468,7 +468,7 @@ function get_colorgradient(series::Series) elseif series[:line_z] !== nothing series[:line_color] elseif series[:fill_z] !== nothing - series[:fillcolor] + series[:yfill_color] end end @@ -481,7 +481,7 @@ get_gradient(cp::ColorPalette) = cgrad(cp, categorical = true) get_linewidth(series, i::Int = 1) = _cycle(series[:line_width], i) get_linestyle(series, i::Int = 1) = _cycle(series[:line_style], i) -get_fillstyle(series, i::Int = 1) = _cycle(series[:fillstyle], i) +get_fillstyle(series, i::Int = 1) = _cycle(series[:yfill_style], i) function get_markerstrokecolor(series, i::Int = 1) msc = series[:marker_stroke_color] @@ -498,9 +498,9 @@ const _segmenting_vector_attributes = ( :line_alpha, :line_width, :line_style, - :fillcolor, - :fillalpha, - :fillstyle, + :yfill_color, + :yfill_alpha, + :yfill_style, :marker_color, :marker_alpha, :marker_size, diff --git a/test/test_defaults.jl b/test/test_defaults.jl index d96f82152..3f2a9869c 100644 --- a/test/test_defaults.jl +++ b/test/test_defaults.jl @@ -12,9 +12,9 @@ Plots._plots_theme_defaults() @testset "default" begin default(fillrange = 0) - @test Plots._series_defaults[:fillrange] == 0 + @test Plots._series_defaults[:yfill_range] == 0 pl = plot(1:5) - @test pl[1][1][:fillrange] == 0 + @test pl[1][1][:yfill_range] == 0 @test_nowarn default(legendfont = font(5)) pl = plot(1:5) @test pl[1][:legend_font_pointsize] == 5 diff --git a/test/test_misc.jl b/test/test_misc.jl index a5f7bd776..8e3f0d391 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -151,11 +151,11 @@ end end @testset "Slicing" begin - @test plot(1:5, fillrange = 0)[1][1][:fillrange] == 0 + @test plot(1:5, fillrange = 0)[1][1][:yfill_range] == 0 data4 = rand(4, 4) mat = reshape(1:8, 2, 4) for i in axes(data4, 1) - for attribute in (:fillrange, :ribbon) + for attribute in (:yfill_range, :ribbon) get_attr(pl) = pl[1][i][attribute] @test plot(data4; NamedTuple{tuple(attribute)}(0)...) |> get_attr == 0 @test plot(data4; NamedTuple{tuple(attribute)}(Ref([1, 2]))...) |> get_attr == @@ -273,7 +273,7 @@ end y, z; connections = [ - [1, 2, 4, 3], # Quadrangle + [1, 2, 4, 3], # Quadrangle [1, 2, 5], # Triangle [2, 4, 5], # Triangle [4, 3, 5], # Triangle