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

Warn on extrakws #4861

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,12 @@ function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes)
end
end
end
supported_extra_kws = extra_supported_kws(pkg)
for kw in keys(extra_kwargs)
if kw ∉ supported_extra_kws
@warn "Extra keyword argument $kw not explicitly supported with $pkg. Choose from: $(join(supported_extra_kws, ", "))"
end
end
extra_kwargs
end

Expand Down
1 change: 1 addition & 0 deletions src/backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ const _base_supported_args = [
:permute,
:unitformat,
]
extra_supported_kws(pkg::AbstractBackend) = []

function merge_with_base_supported(v::AVec)
v = vcat(v, _base_supported_args)
Expand Down
2 changes: 2 additions & 0 deletions src/backends/gr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ const gr_font_family = Dict(
"computer modern" => 232,
"dejavu sans" => 233,
)
extra_supported_kws(::GRBackend) =
[:legend_hfactor, :legend_wfactor, :nx, :ny, :display_option]

mutable struct GRViewport{T}
xmin::T
Expand Down
1 change: 1 addition & 0 deletions src/backends/pgfplotsx.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Options = PGFPlotsX.Options
const Table = PGFPlotsX.Table

extra_supported_kws(::PGFPlotsXBackend) = [:add]
Base.@kwdef mutable struct PGFPlotsXPlot
is_created::Bool = false
was_shown::Bool = false
Expand Down
4 changes: 4 additions & 0 deletions src/backends/pythonplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

is_marker_supported(::PythonPlotBackend, shape::Shape) = true

# As this gets longer perhaps it should be a Set
extra_supported_kws(::PythonPlotBackend) =
[:levels, :mincnt, :edgecolors, :extend3d, :colors, :cmap, :facecolors, :shade]

# problem: github.com/tbreloff/Plots.jl/issues/308
# solution: hack from @stevengj: github.com/JuliaPy/PyPlot.jl/pull/223#issuecomment-229747768
let otherdisplays = splice!(Base.Multimedia.displays, 2:length(Base.Multimedia.displays))
Expand Down
Loading