Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Conversation

SimonDanisch
Copy link
Member

No description provided.

Copy link
Member

@asinghvi17 asinghvi17 left a 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.

end
end

function AbstractPlotting.convert_attribute(cg::PlotUtils.ColorGradient, ::key"colormap", n::Integer=length(cg.values))
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this do?

# 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}}
Copy link
Member

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.

Copy link
Member Author

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!


@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}
Copy link
Member

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!

@SimonDanisch SimonDanisch changed the title document refactor goals document & implement refactor goals Mar 16, 2020
@piever
Copy link
Member

piever commented Mar 17, 2020

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 convert_arguments hack).

I think this is handled well by for example https://github.com/JuliaGPU/Adapt.jl (in a completely different setting). They split adapt in adapt_structure and adapt_storage, which you should overload for wrapper type or innermost type respectively.

@SimonDanisch
Copy link
Member Author

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]>
@piever
Copy link
Member

piever commented Mar 17, 2020

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 @recipe, say

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 redplot(rand(10) .± 0.1). From what I understand, in the refactor this type of approach will be the default, so we need to make sure that this example remains possible.

@SimonDanisch
Copy link
Member Author

Changes in #426

@SimonDanisch SimonDanisch deleted the sd/refactor branch April 27, 2021 08:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants