Open mkborregaard opened 7 years ago
I could do this by pen and paper by looking over the code, but I guess some of the hackers in this organisation could find a way to lift it from the code?
It's a nice idea! I was thinking along these lines as well after the slack chat with @SimonDanisch. I have two questions regarding future plans and one remark:
Question 1: Do we also intend to support changing an attribute that only affects one series? i.e. should it, for example, be allowed to change the line color of the 3rd series? As of now, I don't think that's possible and I wonder whether it should be or if it's just bad practice to build a plot like that.
Question 2: Do we want to distinguish, when updating the attributes, whether one attribute was computed automatically or given by the user? For example, if I give explicit axis[:extrema]
and then modify x
, I probably don't want my axis[:extrema]
to be overwritten.
Remark: As of know, solving this issue would still not allow a fully efficient update of the plot, as the backends only implement one monolithic display function that computes everything. For this proposal to work, the backend code would need to be much more modular, which I think should be taken care of during the Plots.jl reorganization, I'll try to post a more lengthy discussion of this tomorrow in the Plots reorg issue.
Question 1: I think it would normally be bad practice, but I don't see why we couldn't support it. In fact it is supported now:
p = plot(rand(10,2))
p[1][2][:linecolor] = colorant"red"
p
Question 2: Yes.
Remark: great!
I see, but also on Question 1 we need to be careful, as here there is the opposite problem: now we don't update any attribute, so for example:
p = plot(rand(10,2))
p[1][2][:seriescolor] = colorant"red"
p
doesn't do anything, as the :linecolor
attribute doesn't get changed.
Exactly, that's the purpose of mapping the dependency tree :-)
Question 2:
For example, if I give explicit axis[:extrema] and then modify x, I probably don't want my axis[:extrema] to be overwritten.
That's my intuition as well. Actually i have it implemented in GLVisualize like this forever. It also has some other advantages:
1) It's the easiest to implement 2) It also gives the user a way to un-link attributes 3) User can link to other attributes/ link differently
This relies a bit on the assumption, that it's easy for users to build those links themselves - which should be true :)
Remark: couldn't agree more!
Many attributes in
Plot
objects depend on each other:x
affectsaxis[:extrema]
,background_color
affectsforeground_color
affects most other colors, etc. It would be nice to map these depedencies (also to put in the docs). In particular, it would make for much faster updating ofPlot
objects, where you'd push a change, say a new series (e.g. by callingplot!
) or a different background color, and then the rest of the plot would update accordingly, but only updating those attributes that were affected by the change. This is inspired by @SimonDanisch 's ideas in Makie but @tbreloff also talked about this idea a number of times in the past.