Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure marker, line, fill, error attributes #4489

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, :markersize, :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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions RecipesBase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ function RecipesBase.apply_recipe(d::Dict{Symbol,Any},::T,n=1)
end
series_list = RecipesBase.RecipeData[]
func_return = begin
get!(d,:markershape,:auto)
d[:markercolor] = customcolor
get!(d,:marker_shape,:auto)
d[:marker_color] = customcolor
get!(d,:xrotation,45)
get!(d,:zrotation,90)
rand(10,n)
Expand Down
32 changes: 16 additions & 16 deletions RecipesBase/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ end
n::N = 1;
customcolor = :green,
) where {N<:Integer}
:markershape --> :auto, :require
:markercolor --> customcolor, :force
:marker_shape --> :auto, :require
:marker_color --> customcolor, :force
:xrotation --> 5
:zrotation --> 6, :quiet
rand(StableRNG(1), 10, n)
Expand All @@ -77,8 +77,8 @@ end
T1,
KW(
:customcolor => :red,
:markershape => :auto,
:markercolor => :red,
:marker_shape => :auto,
:marker_color => :red,
:xrotation => 5,
:zrotation => 6,
),
Expand All @@ -93,8 +93,8 @@ end
n::N = 1;
customcolor = :green,
) where {N<:Integer}
:markershape --> :auto, :require
:markercolor --> customcolor, :force
:marker_shape --> :auto, :require
:marker_color --> customcolor, :force
:xrotation --> 5
:zrotation --> 6, :quiet
rand(StableRNG(1), 10, n)
Expand All @@ -104,8 +104,8 @@ end
T2,
KW(
:customcolor => :red,
:markershape => :auto,
:markercolor => :red,
:marker_shape => :auto,
:marker_color => :red,
:xrotation => 5,
:zrotation => 6,
),
Expand All @@ -121,8 +121,8 @@ end
m::M = 0.0;
customcolor = :green,
) where {N<:Integer} where {M<:Float64}
:markershape --> :auto, :require
:markercolor --> customcolor, :force
:marker_shape --> :auto, :require
:marker_color --> customcolor, :force
:xrotation --> 5
:zrotation --> 6, :quiet
rand(StableRNG(1), 10, n)
Expand All @@ -132,8 +132,8 @@ end
T3,
KW(
:customcolor => :red,
:markershape => :auto,
:markercolor => :red,
:marker_shape => :auto,
:marker_color => :red,
:xrotation => 5,
:zrotation => 6,
),
Expand All @@ -144,8 +144,8 @@ end
@test_throws MethodError RecipesBase.apply_recipe(KW(), T4())

RecipesBase.@recipe function plot(t::T4, n = 1; customcolor = :green)
:markershape --> :auto, :require
:markercolor --> customcolor, :force
:marker_shape --> :auto, :require
:marker_color --> customcolor, :force
:xrotation --> 5
:zrotation --> 6, :quiet
plotattributes[:hello] = "hi"
Expand All @@ -156,8 +156,8 @@ end
T4,
KW(
:customcolor => :red,
:markershape => :auto,
:markercolor => :red,
:marker_shape => :auto,
:marker_color => :red,
:xrotation => 5,
:zrotation => 6,
:hello => "hi",
Expand Down
2 changes: 1 addition & 1 deletion RecipesPipeline/src/series_recipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import RecipesPipeline:
timeformatter,
needs_3d_axes,
DefaultsDict,
explicitkeys,
scale_func,
is_surface,
Formatted,
Expand Down
34 changes: 17 additions & 17 deletions src/arg_desc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ const _arg_desc = KW(
:seriescolor => "Color Type. The base color for this series. `:auto` (the default) will select a color from the subplot's `color_palette`, based on the order it was added to the subplot",
:seriesalpha => "Number in [0,1]. The alpha/opacity override for the series. `nothing` (the default) means it will take the alpha value of the color.",
:seriestype => "Symbol. This is the identifier of the type of visualization for this series. Choose from $(_allTypes) or any series recipes which are defined.",
:linestyle => "Symbol. Style of the line (for path and bar stroke). Choose from $(_allStyles)",
:linewidth => "Number. Width of the line (in pixels)",
:linecolor => "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).",
:linealpha => "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.",
:markershape => "Symbol, Shape, or AbstractVector. Choose from $(_allMarkers).",
:fillstyle => "Symbol. Style of the fill area. `nothing` (the default) means solid fill. Choose from :/, :\\, :|, :-, :+, :x",
:markercolor => "Color Type. Color of the interior of the marker or shape. `:match` will take the value from `:seriescolor`.",
:markeralpha => "Number in [0,1]. The alpha/opacity override for the marker interior. `nothing` (the default) means it will take the alpha value of markercolor.",
:markersize => "Number or AbstractVector. Size (radius pixels) of the markers",
:markerstrokestyle => "Symbol. Style of the marker stroke (border). Choose from $(_allStyles)",
:markerstrokewidth => "Number. Width of the marker stroke (border) in pixels",
:markerstrokecolor => "Color Type. Color of the marker stroke (border). `:match` will take the value from `:foreground_color_subplot`.",
:markerstrokealpha => "Number in [0,1]. The alpha/opacity override for the marker stroke (border). `nothing` (the default) means it will take the alpha value of markerstrokecolor.",
:line_style => "Symbol. Style of the line (for path and bar stroke). Choose from $(_allStyles)",
: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.",
Comment on lines +13 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
: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.",
: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).",
:yfill_style => "Symbol. Style of the fill area. `nothing` (the default) means solid fill. Choose from :/, :\\, :|, :-, :+, :x",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
:yfill_style => "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",
:marker_stroke_style => "Symbol. Style of the marker stroke (border). Choose from $(_allStyles)",
:marker_stroke_width => "Number. Width of the marker stroke (border) in pixels",
:marker_stroke_color => "Color Type. Color of the marker stroke (border). `:match` will take the value from `:foreground_color_subplot`.",
:marker_stroke_alpha => "Number in [0,1]. The alpha/opacity override for the marker stroke (border). `nothing` (the default) means it will take the alpha value of markerstrokecolor.",
:bins => "Integer, NTuple{2,Integer}, AbstractVector or Symbol. Default is :auto (the Freedman-Diaconis rule). For histogram-types, defines the approximate number of bins to aim for, or the auto-binning algorithm to use (:sturges, :sqrt, :rice, :scott or :fd). For fine-grained control pass a Vector of break values, e.g. `range(minimum(x), stop = maximum(x), length = 25)`",
:smooth => "Bool. Add a regression line?",
:group => "AbstractVector. Data is split into a separate series, one for each unique value in `group`",
Expand Down Expand Up @@ -187,7 +187,7 @@ const _arg_desc = KW(
:showaxis => "Bool, Symbol or String. Show the axis. `true`, `false`, `:show`, `:hide`, `:yes`, `:no`, `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:off`",
:widen => """
Bool, Number or :auto. Widen the axis limits by a small factor to avoid cut-off markers and lines at the borders.
If set to `true`, scale the axis limits by the default factor of $(default_widen_factor).
If set to `true`, scale the axis limits by the default factor of $(default_widen_factor).
A different factor may be specified by setting `widen` to a number.
Defaults to `:auto`, which widens by the default factor unless limits were manually set.
See also the `scale_limits!` function for scaling axis limits in an existing plot.
Expand Down
Loading