-
Notifications
You must be signed in to change notification settings - Fork 65
document & implement refactor goals #360
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting refactor! Couple things I didn't really understand, but looks good. We should definitely allow the toplevel API to stay essentially as it is now, it's pretty powerful IMO.
src/convert_attributes.jl
Outdated
end | ||
end | ||
|
||
function AbstractPlotting.convert_attribute(cg::PlotUtils.ColorGradient, ::key"colormap", n::Integer=length(cg.values)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move this up near the rest of the color code.
src/theming.jl
Outdated
raw = false, | ||
) | ||
|
||
plot_name(::AbstractPlot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this do?
src/attributes.jl
Outdated
# We dont have one node per value anymore, but instead one node | ||
# that gets triggered on any setindex!, or whenever an input attribute node changes | ||
# This makes it easier to layer Observable{Attributes}() | ||
on_change::Node{Pair{Symbol, Any}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this, would a re-render be forced whenever you update scene.color
? I'm not sure how this would work, would appreciate some clarification here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That never triggered a rerender in opengl, and still wont ;) But I guess will trigger one in other frameworks... But its essentially not different from the Attribute type before, just an optimized implementation!
src/attributes.jl
Outdated
|
||
@generated hasfield(x::T, ::Val{key}) where {T, key} = :($(key in fieldnames(T))) | ||
|
||
function Base.getproperty(x::T, key::Symbol) where T <: Union{Attributes, Transformable} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also define propertynames
!
Co-Authored-By: Anshul Singhvi <[email protected]>
Co-Authored-By: Anshul Singhvi <[email protected]>
…jl into sd/refactor
Not sure if this is the right place to comment, but here's one thing that came out (when playing with the "algebra of graphics" stuff). I think the new transform pipeline should be designed in such a way that it could be overloaded either based on the plot type for all arguments (already possible) or on the argument types for all plots (not easy right now, only I think this is handled well by for example https://github.com/JuliaGPU/Adapt.jl (in a completely different setting). They split |
Can you give me 2 concrete examples so that I can add them to the tests for the new pipeline? |
Co-Authored-By: Anshul Singhvi <[email protected]>
Mhm, actually by exploring a bit more, I think it was a matter of finding the right method, and it already works well (I'll try to see if it's powerful enough to support grammar of graphics). I think I had a misconception on how this is done in Makie. So, one example (overload on the arguments) could be for the Measurements package. julia> using Measurements: ±, value, uncertainty, Measurement
julia> using AbstractPlotting
julia> using AbstractPlotting: SceneLike, PlotFunc
julia> function AbstractPlotting.plot!(scn::SceneLike, P::PlotFunc, attr::Attributes, v::Vector{<:Measurement})
val = value.(v)
u = uncertainty.(v)
plot!(scn, P, attr, val)
plot!(scn, Band, attr, 1:length(v), val - u, val + u)
return scn
end And now, if I define a custom recipe with julia> using Colors
julia> @recipe(RedPlot, x) do scene
default_theme(scene)
end
julia> AbstractPlotting.plot!(plot::RedPlot) = lines!(plot, plot[:x], color = colorant"red") I can already do |
Changes in #426 |
No description provided.