Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map dependency tree of Plots' attributes #1149

Open
mkborregaard opened this issue Oct 8, 2017 · 6 comments
Open

map dependency tree of Plots' attributes #1149

mkborregaard opened this issue Oct 8, 2017 · 6 comments

Comments

@mkborregaard
Copy link
Member

Many attributes in Plot objects depend on each other: x affects axis[:extrema], background_color affects foreground_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 of Plot objects, where you'd push a change, say a new series (e.g. by calling plot!) 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.

@mkborregaard
Copy link
Member Author

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?

@piever
Copy link
Member

piever commented Oct 10, 2017

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.

@mkborregaard
Copy link
Member Author

mkborregaard commented Oct 11, 2017

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

skaermbillede 2017-10-11 kl 09 17 56

Question 2: Yes.

Remark: great!

@piever
Copy link
Member

piever commented Oct 11, 2017

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.

@mkborregaard
Copy link
Member Author

Exactly, that's the purpose of mapping the dependency tree :-)

@SimonDanisch
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants