From 0efda094883c6df3750ea43ed75a2f0aa1d0d284 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 10 Nov 2022 22:04:58 +0100 Subject: [PATCH] Revert "rename yfill -> fill" This reverts commit da25f973fbab216498cdb0c96268e43b9778b76d. --- NEWS.md | 4 +- RecipesPipeline/src/series_recipe.jl | 2 +- src/arg_desc.jl | 8 ++-- src/args.jl | 45 ++++++++++++---------- src/axes.jl | 4 +- src/backends.jl | 46 +++++++++++------------ src/backends/deprecated/pgfplots.jl | 10 ++--- src/backends/gaston.jl | 4 +- src/backends/gr.jl | 20 +++++----- 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 | 26 ++++++------- src/unitful.jl | 2 +- src/utils.jl | 22 +++++------ test/test_defaults.jl | 4 +- test/test_misc.jl | 4 +- 19 files changed, 148 insertions(+), 141 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8eb76b21e..8e8d79d40 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: - - `(:yfill_range, :line_z, :marker_z, :marker_size, :ribbon, :weights, :xerror, :yerror)` + - `(:fillrange, :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 `:yfill_range` and `zcolor` arguments (for example: `scatter(sin, 0:10, marker=15, fill=(cos,0.4), zcolor=sin)`) +- allow Function for `:fillrange` 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 8f8cdc9bc..bb4275803 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[:yfill_range] = nothing + plotattributes[:fillrange] = 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 a62cba8f6..f85d02d2d 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.", - :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.", + :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.", :marker_shape => "Symbol, Shape, or AbstractVector. Choose from $(_allMarkers).", - :yfill_style => "Symbol. Style of the fill area. `nothing` (the default) means solid fill. Choose from :/, :\\, :|, :-, :+, :x", + :fillstyle => "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 6b4be8feb..5705891b3 100644 --- a/src/args.jl +++ b/src/args.jl @@ -338,6 +338,10 @@ 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 @@ -573,6 +577,7 @@ add_aliases(:right_margin, :rightmargin) # colors add_aliases(:seriescolor, :c, :color, :colour) +add_aliases(:fillcolor, :fc, :fcolor, :fcolour, :fillcolour) add_aliases( :background_color, @@ -787,6 +792,7 @@ add_aliases( # alphas add_aliases(:seriesalpha, :alpha, :α, :opacity) +add_aliases(:fillalpha, :fa, :falpha, :fα, :fillopacity, :fopacity) # axes attributes add_axes_aliases(:guide, :label, :lab, :l; generic = false) @@ -870,6 +876,7 @@ add_aliases(:marker, :m, :mark) 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(:group, :g, :grouping) add_aliases(:bins, :bin, :nbin, :nbins, :nb) add_aliases(:ribbon, :rib) @@ -1084,13 +1091,13 @@ function processLineArg(plotattributes::AKW, arg) arg.style === nothing || (plotattributes[:line_style] = arg.style) elseif typeof(arg) <: Brush - arg.size === nothing || (plotattributes[:yfill_range] = arg.size) + arg.size === nothing || (plotattributes[:fillrange] = arg.size) arg.color === nothing || ( - plotattributes[:yfill_color] = + plotattributes[:fillcolor] = arg.color === :auto ? :auto : plot_color(arg.color) ) - arg.alpha === nothing || (plotattributes[:yfill_alpha] = arg.alpha) - arg.style === nothing || (plotattributes[:yfill_style] = arg.style) + arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha) + arg.style === nothing || (plotattributes[:fillstyle] = arg.style) elseif typeof(arg) <: Arrow || arg in (:arrow, :arrows) plotattributes[:arrow] = arg @@ -1154,35 +1161,35 @@ function processMarkerArg(plotattributes::AKW, arg) end function processFillArg(plotattributes::AKW, arg) - # fr = get(plotattributes, :yfill_range, 0) + # fr = get(plotattributes, :fillrange, 0) if typeof(arg) <: Brush - arg.size === nothing || (plotattributes[:yfill_range] = arg.size) + arg.size === nothing || (plotattributes[:fillrange] = arg.size) arg.color === nothing || ( - plotattributes[:yfill_color] = + plotattributes[:fillcolor] = arg.color === :auto ? :auto : plot_color(arg.color) ) - arg.alpha === nothing || (plotattributes[:yfill_alpha] = arg.alpha) - arg.style === nothing || (plotattributes[:yfill_style] = arg.style) + arg.alpha === nothing || (plotattributes[:fillalpha] = arg.alpha) + arg.style === nothing || (plotattributes[:fillstyle] = arg.style) elseif typeof(arg) <: Bool - plotattributes[:yfill_range] = arg ? 0 : nothing + plotattributes[:fillrange] = arg ? 0 : nothing # fillrange function elseif allFunctions(arg) - plotattributes[:yfill_range] = arg + plotattributes[:fillrange] = arg # fillalpha elseif allAlphas(arg) - plotattributes[:yfill_alpha] = arg + plotattributes[:fillalpha] = arg # fillrange provided as vector or number elseif typeof(arg) <: Union{AbstractArray{<:Real},Real} - plotattributes[:yfill_range] = arg + plotattributes[:fillrange] = arg - elseif !handleColors!(plotattributes, arg, :yfill_color) - plotattributes[:yfill_range] = arg + elseif !handleColors!(plotattributes, arg, :fillcolor) + plotattributes[:fillrange] = arg end - # plotattributes[:yfill_range] = fr + # plotattributes[:fillrange] = fr nothing end @@ -2039,7 +2046,7 @@ function _update_series_attributes!(plotattributes::AKW, plt::Plot, sp::Subplot) ) # update alphas - for asym in (:line_alpha, :marker_alpha, :yfill_alpha) + for asym in (:line_alpha, :marker_alpha, :fillalpha) if plotattributes[asym] === nothing plotattributes[asym] = plotattributes[:seriesalpha] end @@ -2054,7 +2061,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_, :yfill_) + for s in (:line_, :marker_, :fill) 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 @@ -2086,7 +2093,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, :yfill_color, :yfill_alpha) + ensure_gradient!(plotattributes, :fillcolor, :fillalpha) end # scatter plots don't have a line, but must have a shape diff --git a/src/axes.jl b/src/axes.jl index c04fb30d5..3f6470aa7 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -453,7 +453,7 @@ function expand_extrema!(sp::Subplot, plotattributes::AKW) # end # expand for fillrange - fr = plotattributes[:yfill_range] + fr = plotattributes[:fillrange] if fr === nothing && plotattributes[:seriestype] === :bar fr = 0.0 end @@ -512,7 +512,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 4bccaf0ba..71cd5b129 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, - :yfill_range, - :yfill_color, - :yfill_alpha, - :yfill_style, + :fillrange, + :fillcolor, + :fillalpha, + :fillstyle, :bins, :layout, :title, @@ -448,9 +448,9 @@ const _plotly_attr = merge_with_base_supported([ :marker_stroke_color, :marker_stroke_alpha, :marker_stroke_style, - :yfill_range, - :yfill_color, - :yfill_alpha, + :fillrange, + :fillcolor, + :fillalpha, :bins, :title, :titlelocation, @@ -573,9 +573,9 @@ const _pgfplots_attr = merge_with_base_supported([ :marker_stroke_color, :marker_stroke_alpha, :marker_stroke_style, - :yfill_range, - :yfill_color, - :yfill_alpha, + :fillrange, + :fillcolor, + :fillalpha, :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, - :yfill_range, - :yfill_color, - :yfill_alpha, - :yfill_style, + :fillrange, + :fillcolor, + :fillalpha, + :fillstyle, :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, - # :yfill_range, :yfill_color, :yfill_alpha, + # :fillrange, :fillcolor, :fillalpha, # :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, - :yfill_range, - :yfill_color, - :yfill_alpha, + :fillrange, + :fillcolor, + :fillalpha, :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? - :yfill_color, - :yfill_alpha, #:yfill_range, + :fillcolor, + :fillalpha, #:fillrange, # :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, - :yfill_range, - :yfill_color, - :yfill_alpha, + :fillrange, + :fillcolor, + :fillalpha, :bins, :layout, :title, diff --git a/src/backends/deprecated/pgfplots.jl b/src/backends/deprecated/pgfplots.jl index 2c241a63a..780ecf748 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[:yfill_range] !== nothing + if plotattributes[:fillrange] !== nothing push!(style, "forget plot") push!(series_collection, pgf_fill_legend_hack(plotattributes, args)) else kw[:legendentry] = plotattributes[:label] - if st === :shape # || plotattributes[:yfill_range] !== nothing + if st === :shape # || plotattributes[:fillrange] !== 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[:yfill_range] !== nothing && st !== :shape + if series[:fillrange] !== nothing && st !== :shape push!( series_collection, pgf_fillrange_series( series, i, - _cycle(series[:yfill_range], rng), + _cycle(series[:fillrange], 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, :yfill_color, :line_color) + for col in (:marker_color, :fillcolor, :line_color) if typeof(series.plotattributes[col]) == ColorGradient push!( style, diff --git a/src/backends/gaston.jl b/src/backends/gaston.jl index 955723721..b19ec5c84 100644 --- a/src/backends/gaston.jl +++ b/src/backends/gaston.jl @@ -219,7 +219,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[:yfill_range], 1:length(x[rng])) + fr = _cycle(series[:fillrange], 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 @@ -293,7 +293,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[:yfill_range] + fr = series[:fillrange] 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 89296cf26..065299b26 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1010,7 +1010,7 @@ function gr_add_legend(sp, leg, viewport_area) _debugMode[] && gr_legend_bbox(xpos, ypos, leg) if ( - (st === :shape || series[:yfill_range] !== nothing) && + (st === :shape || series[:fillrange] !== nothing) && series[:ribbon] === nothing ) (fc = get_fillcolor(series, clims)) |> gr_set_fill @@ -1649,7 +1649,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[:yfill_range] + frng = series[:fillrange] # recompute data if ispolar(sp) && z === nothing @@ -1829,7 +1829,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[:yfill_range] !== nothing + if series[:fillrange] !== nothing GR.contourf(x, y, h, z, series[:contour_labels] == true ? 1 : 0) else black = plot_color(:black) @@ -1885,10 +1885,10 @@ function gr_draw_surface(series, x, y, z, clims) ArgumentError |> throw end - facecolor = if series[:yfill_color] isa AbstractArray - series[:yfill_color] + facecolor = if series[:fillcolor] isa AbstractArray + series[:fillcolor] else - fill(series[:yfill_color], length(cns)) + fill(series[:fillcolor], length(cns)) end fillalpha = get_fillalpha(series) facecolor = map(fc -> set_RGBA_alpha(fillalpha, fc), facecolor) @@ -1902,7 +1902,7 @@ function gr_draw_surface(series, x, y, z, clims) end function gr_draw_heatmap(series, x, y, z, clims) - fillgrad = _as_gradient(series[:yfill_color]) + fillgrad = _as_gradient(series[:fillcolor]) GR.setprojectiontype(0) GR.setspace(clims..., 0, 90) w, h = length(x) - 1, length(y) - 1 @@ -1914,18 +1914,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[:yfill_alpha]), z + plot_color.(get(fillgrad, z, clims), series[:fillalpha]), 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[:yfill_alpha]), z_log + plot_color.(map(z -> get(fillgrad, z), z_normalized), series[:fillalpha]), 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[:yfill_alpha], 1) < 1 + if something(series[:fillalpha], 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 21cf8bc3b..0411f3d38 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[:yfill_color] #I think this is fill under line + series[:fillcolor] #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 c04fd5f70..fcf95085f 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[:yfill_range] !== nothing && + series[:fillrange] !== 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[:yfill_range]) !== nothing && !isfilledcontour(series) + if (sf = opt[:fillrange]) !== 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 dd20dfc7c..eff913e5d 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[:yfill_range], AbstractVector) || isa(series[:yfill_range], Tuple)) + (isa(series[:fillrange], AbstractVector) || isa(series[:fillrange], 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[:yfill_color], series[:yfill_alpha]) + plotly_colorscale(series[:fillcolor], series[:fillalpha]) 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[:yfill_color], series[:yfill_alpha]) - plotattributes_out[:opacity] = series[:yfill_alpha] + plotly_colorscale(series[:fillcolor], series[:fillalpha]) + plotattributes_out[:opacity] = series[:fillalpha] 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[:yfill_color], series[:yfill_alpha]) + plotly_colorscale(series[:fillcolor], series[:fillalpha]) plotattributes_out[:color] = - rgba_string(plot_color(series[:yfill_color], series[:yfill_alpha])) - plotattributes_out[:opacity] = series[:yfill_alpha] + rgba_string(plot_color(series[:fillcolor], series[:fillalpha])) + plotattributes_out[:opacity] = series[:fillalpha] 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", - :yfill_color => rgba_string( + :fillcolor => 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[:yfill_range], AbstractVector) || isa(series[:yfill_range], Tuple)) + (isa(series[:fillrange], AbstractVector) || isa(series[:fillrange], 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[:yfill_range] == true || - series[:yfill_range] == 0 || - isa(series[:yfill_range], Tuple) + if series[:fillrange] == true || + series[:fillrange] == 0 || + isa(series[:fillrange], Tuple) plotattributes_out[:fill] = "tozeroy" - plotattributes_out[:yfill_color] = rgba_string( + plotattributes_out[:fillcolor] = rgba_string( plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)), ) - elseif typeof(series[:yfill_range]) <: Union{AbstractVector{<:Real},Real} + elseif typeof(series[:fillrange]) <: Union{AbstractVector{<:Real},Real} plotattributes_out[:fill] = "tonexty" - plotattributes_out[:yfill_color] = rgba_string( + plotattributes_out[:fillcolor] = rgba_string( plot_color(get_fillcolor(series, clims, i), get_fillalpha(series, i)), ) - 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])" + elseif !(series[:fillrange] in (false, nothing)) + @warn "fillrange ignored... plotly only supports filling to zero and to a vector of values. fillrange: $(series[:fillrange])" 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[:yfill_range]) <: Real - plotattributes_out[:yfill_range] = fill(series[:yfill_range], length(rng)) - elseif typeof(series[:yfill_range]) <: Tuple + if typeof(series[:fillrange]) <: Real + plotattributes_out[:fillrange] = fill(series[:fillrange], length(rng)) + elseif typeof(series[:fillrange]) <: Tuple f1 = - (fr1 = series[:yfill_range][1]) |> typeof <: Real ? + (fr1 = series[:fillrange][1]) |> typeof <: Real ? fill(fr1, length(rng)) : fr1[rng] f2 = - (fr2 = series[:yfill_range][2]) |> typeof <: Real ? + (fr2 = series[:fillrange][2]) |> typeof <: Real ? fill(fr2, length(rng)) : fr2[rng] - plotattributes_out[:yfill_range] = (f1, f2) + plotattributes_out[:fillrange] = (f1, f2) end - if isa(series[:yfill_range], AbstractVector) - plotattributes_out_fillrange[:y] = series[:yfill_range][rng] + if isa(series[:fillrange], AbstractVector) + plotattributes_out_fillrange[:y] = series[:fillrange][rng] delete!(plotattributes_out_fillrange, :fill) - delete!(plotattributes_out_fillrange, :yfill_color) + delete!(plotattributes_out_fillrange, :fillcolor) 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[:yfill_range]) + concatenate_fillrange(x[rng], series[:fillrange]) plotattributes_out_fillrange[:line][:width] = 0 delete!(plotattributes_out, :fill) - delete!(plotattributes_out, :yfill_color) + delete!(plotattributes_out, :fillcolor) end plotattributes_outs[(2k - 1):(2k)] = diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 8bbcc1f7a..b06445550 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[:yfill_color], alpha = get_fillalpha(series))) + py_colormap(cgrad(series[:fillcolor], 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[:yfill_alpha], + alpha = series[:fillalpha], 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[:yfill_range] !== nothing + if series[:fillrange] !== 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[:yfill_alpha], + alpha = series[:fillalpha], 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[:yfill_color], py_handle_surface(series[:fill_z])) + py_shading(series[:fillcolor], 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[:yfill_color]), + facecolor = py_color(series[:fillcolor]), 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[:yfill_color]) + handle._facecolors2d = py_color(series[:fillcolor]) 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[:yfill_alpha], + alpha = series[:fillalpha], # 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[:yfill_range] + fillrange = series[:fillrange] if fillrange !== nothing && st !== :contour for segment in series_segments(series) i, rng = segment.attr_index, segment.range @@ -1466,7 +1466,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) nseries += 1 clims = get_clims(sp, series) # add a line/marker and a label - if series[:seriestype] === :shape || series[:yfill_range] !== nothing + if series[:seriestype] === :shape || series[:fillrange] !== 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 ced8c383f..2f62e38ff 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, - :yfill_range => nothing, + :fillrange => nothing, :label => "", :primary => false, ), @@ -176,7 +176,7 @@ function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_l kw[:z_extrema] = ze rib = get(kw, :ribbon, default(:ribbon)) - fr = get(kw, :yfill_range, default(:yfill_range)) + fr = get(kw, :fillrange, default(:fillrange)) # map ribbon if it's a Function if rib isa Function kw[:ribbon] = map(rib, kw[:x]) @@ -186,7 +186,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[:yfill_range] = map(fr, kw[:x]) + kw[:fillrange] = map(fr, kw[:x]) end end nothing diff --git a/src/recipes.jl b/src/recipes.jl index 4ee9b6c01..7ba13c8d5 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -51,8 +51,8 @@ const POTENTIAL_VECTOR_ARGUMENTS = [ :line_width, :line_style, :line_z, - :yfill_color, - :yfill_alpha, + :fillcolor, + :fillalpha, :fill_z, :marker_color, :marker_alpha, @@ -64,7 +64,7 @@ const POTENTIAL_VECTOR_ARGUMENTS = [ :yerror, :zerror, :series_annotations, - :yfill_range, + :fillrange, ] @nospecialize @@ -82,11 +82,11 @@ const POTENTIAL_VECTOR_ARGUMENTS = [ end # a tuple as fillrange has to be handled differently - if typeof(plotattributes[:yfill_range]) <: Tuple - lower, upper = plotattributes[:yfill_range] + if typeof(plotattributes[:fillrange]) <: Tuple + lower, upper = plotattributes[:fillrange] typeof(lower) <: AVec && (lower = _cycle(lower, indices)) typeof(upper) <: AVec && (upper = _cycle(upper, indices)) - plotattributes[:yfill_range] = (lower, upper) + plotattributes[:fillrange] = (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[:yfill_range] = make_steps(plotattributes[:yfill_range], :pre, false) + plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :pre, false) # create a secondary series for the markers if plotattributes[:marker_shape] !== :none @@ -243,7 +243,7 @@ end seriestype := :path # handle fillrange - plotattributes[:yfill_range] = make_steps(plotattributes[:yfill_range], :post, true) + plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post, true) # create a secondary series for the markers if plotattributes[:marker_shape] !== :none @@ -268,7 +268,7 @@ end seriestype := :path # handle fillrange - plotattributes[:yfill_range] = make_steps(plotattributes[:yfill_range], :post, false) + plotattributes[:fillrange] = make_steps(plotattributes[:fillrange], :post, false) # create a secondary series for the markers if plotattributes[:marker_shape] !== :none @@ -430,7 +430,7 @@ end end # make fillto a vector... default fills to 0 - if (fillto = plotattributes[:yfill_range]) === nothing + if (fillto = plotattributes[:fillrange]) === nothing fillto = 0 end if yscale in _logScales && !all(_is_positive, fillto) @@ -510,7 +510,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, :yfill_color, :yfill_alpha) + ensure_gradient!(plotattributes, :fillcolor, :fillalpha) fill_z := fz line_z := fz x := x_pts @@ -1340,7 +1340,7 @@ end yflip --> true colorbar --> false aspect_ratio --> :equal - z, plotattributes[:yfill_color] = replace_image_with_heatmap(mat) + z, plotattributes[:fillcolor] = replace_image_with_heatmap(mat) SliceIt, m, n, Surface(z) end end @@ -1405,7 +1405,7 @@ end seriestype := :heatmap yflip --> true colorbar --> false - z, plotattributes[:yfill_color] = replace_image_with_heatmap(mat) + z, plotattributes[:fillcolor] = replace_image_with_heatmap(mat) SliceIt, x, y, Surface(z) end end diff --git a/src/unitful.jl b/src/unitful.jl index 1ac542952..e5552b5d5 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, :yfill_range, u) + ustripattribute!(attr, :fillrange, u) end fixaspectratio!(attr, u, axisletter) fixmarkercolor!(attr) diff --git a/src/utils.jl b/src/utils.jl index 31b0d4d35..29467dccb 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -384,8 +384,8 @@ function make_fillrange_from_ribbon(kw::AKW) rib = wraptuple(rib) rib1, rib2 = -first(rib), last(rib) # kw[:ribbon] = nothing - kw[:yfill_range] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2) - (get(kw, :yfill_alpha, nothing) === nothing) && (kw[:yfill_alpha] = 0.5) + kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2) + (get(kw, :fillalpha, nothing) === nothing) && (kw[:fillalpha] = 0.5) end #turn tuple of fillranges to one path @@ -425,7 +425,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[:yfill_range] !== nothing +isfilledcontour(series::Series) = iscontour(series) && series[:fillrange] !== nothing function contour_levels(series::Series, clims) iscontour(series) || error("Not a contour series") @@ -438,7 +438,7 @@ function contour_levels(series::Series, clims) levels end -for comp in (:line_, :yfill_, :marker_) +for comp in (:line_, :fill, :marker_) compcolor = string(comp, :color) get_compcolor = Symbol(:get_, compcolor) comp_z = string(comp, :z) @@ -448,7 +448,7 @@ for comp in (:line_, :yfill_, :marker_) @eval begin function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1) - c = series[$Symbol($compcolor)] # series[:line_color], series[:yfill_color], series[:marker_color] + c = series[$Symbol($compcolor)] # series[:line_color], series[:fillcolor], 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)) @@ -475,7 +475,7 @@ end function get_colorgradient(series::Series) st = series[:seriestype] if st in (:surface, :heatmap) || isfilledcontour(series) - series[:yfill_color] + series[:fillcolor] elseif st in (:contour, :wireframe) series[:line_color] elseif series[:marker_z] !== nothing @@ -483,7 +483,7 @@ function get_colorgradient(series::Series) elseif series[:line_z] !== nothing series[:line_color] elseif series[:fill_z] !== nothing - series[:yfill_color] + series[:fillcolor] end end @@ -496,7 +496,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[:yfill_style], i) +get_fillstyle(series, i::Int = 1) = _cycle(series[:fillstyle], i) function get_markerstrokecolor(series, i::Int = 1) msc = series[:marker_stroke_color] @@ -513,9 +513,9 @@ const _segmenting_vector_attributes = ( :line_alpha, :line_width, :line_style, - :yfill_color, - :yfill_alpha, - :yfill_style, + :fillcolor, + :fillalpha, + :fillstyle, :marker_color, :marker_alpha, :marker_size, diff --git a/test/test_defaults.jl b/test/test_defaults.jl index 3f2a9869c..d96f82152 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[:yfill_range] == 0 + @test Plots._series_defaults[:fillrange] == 0 pl = plot(1:5) - @test pl[1][1][:yfill_range] == 0 + @test pl[1][1][:fillrange] == 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 dd194bc34..11c26a20b 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -158,7 +158,7 @@ end end @testset "Slicing" begin - @test plot(1:5, fillrange = 0)[1][1][:yfill_range] == 0 + @test plot(1:5, fillrange = 0)[1][1][:fillrange] == 0 data4 = rand(4, 4) mat = reshape(1:8, 2, 4) sp = plot(data4, ribbon = (mat, mat))[1] @@ -287,7 +287,7 @@ with(:gr) do 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