Plotly: Remove argument checking for levels
Checking of the `levels` keyword argument will be moved out of individual backends' code, so we can assume that `levels` if present in `plotattributes` is either an `AbstractVector` or `Integer`.
This commit is contained in:
parent
fbabf50f5a
commit
33a7e12ae8
@ -621,8 +621,9 @@ function plotly_series(plt::Plot, series::Series)
|
||||
:coloring => filled ? "fill" : "lines",
|
||||
:showlabels => series[:contour_labels] == true,
|
||||
)
|
||||
# Plotly does not support arbitrary sets of contours:
|
||||
# https://github.com/plotly/plotly.js/issues/4503
|
||||
# Plotly does not support arbitrary sets of contours
|
||||
# (https://github.com/plotly/plotly.js/issues/4503)
|
||||
# so we distinguish AbstractRanges and AbstractVectors
|
||||
let levels = series[:levels]
|
||||
if levels isa AbstractRange
|
||||
plotattributes_out[:contours][:start] = first(levels)
|
||||
@ -638,10 +639,9 @@ function plotly_series(plt::Plot, series::Series)
|
||||
"setting arbitrary contour levels with Plotly backend is not supported; " *
|
||||
"use a range to set equally-spaced contours or an integer to set the " *
|
||||
"approximate number of contours with the keyword `levels`. " *
|
||||
"Using levels $(levels_range)"
|
||||
"Setting levels to $(levels_range)"
|
||||
)
|
||||
elseif isinteger(levels)
|
||||
# Assume this is a number of levels
|
||||
elseif levels isa Integer
|
||||
plotattributes_out[:ncontours] = levels + 2
|
||||
end
|
||||
end
|
||||
|
||||
@ -46,7 +46,7 @@ using Plots, Test
|
||||
"setting arbitrary contour levels with Plotly backend " *
|
||||
"is not supported; use a range to set equally-spaced contours or an " *
|
||||
"integer to set the approximate number of contours with the keyword " *
|
||||
"`levels`. Using levels -1.0:0.5:1.0",
|
||||
"`levels`. Setting levels to -1.0:0.5:1.0",
|
||||
) Plots.plotly_series(p)
|
||||
@test series_dict[1][:contours][:start] == first(levels_range)
|
||||
@test series_dict[1][:contours][:end] == last(levels_range)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user