Makie.jl
Makie.jl copied to clipboard
contor with no points: draw nothing instead of throwing an error
Heyo,
So, as mentioned in #2077 I have some data that starts off with no points (and can drop down to 0-1 points) that I want to draw contour lines from.
Unfortunately, this isn't as easy as calling contour! on the data observers.
With zero points, you see this error:
julia> contour([], [], [])
ERROR: `Makie.convert_arguments` for the plot type Combined{Makie.contour, Tuple{Vector{Any}, Vector{Any}, Vector{Any}}} and its conversion trait ContinuousSurface() was unsuccessful.
The signature that could not be converted was:
::Vector{Any}, ::Vector{Any}, ::Vector{Any}
With one point, you see this error:
julia> contour([1], [1], [1])
ERROR: Can't interpolate in a range where cmin == cmax. This can happen, for example, if a colorrange is set automatically but there's only one unique value present.
I feel like it would be rather reasonable with 0-1 points to just not draw anything.
Have you actually tried the suggestion from the error message as a work around?
contour([1], [1], [1]; colorrange=(0, 1))
Seems to work fine and also allows updating the plot.
Have you actually tried the suggestion from the error message as a work around?
I have, but that only helps in the 1-point case, and so doesn't actually help me at all.
Also, even if that did fix it, it would feel like a cludge as I'd have to turn that into an observable to change the colour range based on the data with a 1-point special case.
Well, 10x better then deleting the plot object ;)
I have, but that only helps in the 1-point case, and so doesn't actually help me at all.
Can you supply an example? This has 0 points and works:
f, ax, pl = contour(zeros(5, 5); colorrange=(0, 1))
Isn't that a set of 0-valued points, not 0 points? I mean this:
contour([], [], []; colorrange=(0, 1))
Ah, sorry... When you said points, I was thinking of the line points, and not some input matrix/vector... Yeah ok that still doesn't work.
contour([], [], []; colorrange=(0, 1))
Well for one I think you need to type those vectors because there are no conversion methods for Any vectors