JuliaPlots / RecipesPipeline.jl

Utilities for processing recipes
http://juliaplots.org/RecipesPipeline.jl/dev/
MIT License
17 stars 17 forks source link

Support segments #120

Closed AlexRobson closed 2 years ago

AlexRobson commented 2 years ago

In Plots at some point there was a switch in how representing how segments were handled going from:

[1.0, 1.0, NaN, 1.0, 1.0, NaN, 1.0, 1.0, NaN]

To:

[[1.0, 1.0], [1.0, 1.0], [1.0, 1.0]]

In Intervals, recipes are used to plot the segments for each Interval. So these segments look like:

[[DateTime("2017-01-01T00:00:00"), DateTime("2017-01-01T01:00:00")], [DateTime("2017-01-01T01:00:00"), DateTime("2017-01-01T02:00:00")]

I have an MR that updated that, however I've found that it was not working when using such DateTime types. I believe the issue is here. I'm not too sure on the internals of the package, but I believe that we need to add these methods, and top of these original recipes:

@recipe f(::Type{DateTime}, dt::DateTime) = # Existing 
    (dt -> Dates.value(dt), datetimeformatter)
@recipe f(::Type{Vector{T}}, dt::Vector{T}) where {T<:DateTime} = 
    (dt -> Dates.value.(dt), datetimeformatter) # New method

This MR simply adds these. Testing with my branch in Intervals, this does create the correct plots. It is unclear whether additional tests are needed, as it looks like this uses a test suite from Plots.

Related: https://github.com/invenia/Intervals.jl/issues/159


EDIT: Closing this. I've misunderstood the workings of the package here.