-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Trisurf and color optimizations #499
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
Conversation
@Kully @theengineear I'd be curious to hear your thoughts! |
Well it's awesome that it saves even more time once again. I'm trying it out now. I think your drawback is mine as well. I feel like it would be ideal for matplotlib to not be dependant in this way. I'm wondering if we can do something like check In addition, we could provide a helpful Plotly message upon plotting that could recommend installing matplotlib to speed up the computation time, etc. |
I think that's a fair point. Do you guys have an idea for how many users don't also use matplotlib? My guess is that it'd be a really tiny fraction, but I'm probably not privy to the kinds of userbases that plotly covers. I think that both usecases could be supported, it'd just require a lot of extra lines of code to duplicate the same functionality. I'm generally a fan of changes that reduce the number of lines of code, but understand if you all don't want a dependency on matplotlib. If you guys do prefer custom code over matplotlib, I think it's worth cleaning up the color interpolation so that it A. accepts arrays instead of looping over lists, and B. is a little bit more readable (I'm still not sure what all the |
Andrew and I (mostly Andrew) made this part of the code more clear. It looks like |
yeah, I was taking a look at that before deciding to just use matplotlib colormaps. That's still confusing me a bit. |
Wow, the glorious floor function! I didn't think about that! Although I don't think it would work for some small neighborhood around t=0, right? |
I think the bigger edge case problem would be around t=1, because if t == On Wed, Jun 8, 2016 at 11:26 AM, Adam Kulidjian [email protected]
|
With my code, I just had a simple check for t==1: |
ya, I think that's a good way to handle it, the question is how to vectorize the process. Maybe it'd be possible to use |
1266151
to
728780a
Compare
728780a
to
fbe8d2a
Compare
Hey folks - I updated this so that it doesn't depend on matplotlib. Basically just wrote our own color blending function (maybe it'll be useful elsewhere?) What do you all think? (sorry for the slow update on this...was off backpacking in yellowstone!) |
@choldgraf looks useful to me! @Kully do you think we could integrate this? Might be nice to have a |
Let me know if you want me to try moving color stuff into its own module...that might be a bigger PR than this one though. |
Do you think it's necessary right now? I mean, it's forseeable that we'll eventually need it as we keep adding to the color capabilities. For now it's pretty manageable in |
IMO I don't think that it's a necessary change. Though I bet there are points in the codebase where things are being duplicated because it wasn't clear that the functionality is already there. E.g. that |
That's a good point. But that would be such a big project then, to replace all the linear interpolation code; Make a color class and methods in that... |
yeah I agree that it'd be a bigger project. FWIW I wrote a class that does On Sat, Jun 25, 2016 at 3:33 PM, Adam Kulidjian [email protected]
|
This looks really good Chris. I'd be interested in pulling this repo and playing around with it to see its capabilities. Let me check it out today and I can get back to you. But it looks really clean! 😄 |
Sounds good - it's nothing super fancy...basically just turning a lot of different color representations into a LinearSegmentedColormap and then letting you slice/dice/bin it quickly. Lemme know if it's useful! Anything else for me to do on this PR by the way? |
I think that's fine. To restate what's going on, is your plan to add this color file to this PR and nothing else? I suppose rewriting the FF code to use your module is another PR |
Well, my guess is that plotly would want a pared down version of that class I think a much bigger project would be going through the code and figuring On Mon, Jun 27, 2016 at 9:04 AM, Adam Kulidjian [email protected]
|
I agree. I didn't know your thing has dependancies. |
Sounds good - with the On Mon, Jun 27, 2016 at 9:47 AM, Adam Kulidjian [email protected]
|
@chriddyp @theengineear Hey again Chris. I've been working on rewriting a lot of I am going to try writing a I'll let you know how this goes when I get somewhere. |
No worries - it's been a while on this PR, but I believe the latest commit removes all the matplotlib dependencies. It just has its own interpolating functions under the hood. We could get this pulled and then you can iterate off of that if you like, LMK what you'd prefer |
Oh, I didn't realize/remember that. I would prefer to get my hands wet with my own |
I'm pretty sure this PR just adds an extra https://github.com/plotly/plotly.py/pull/499/files#diff-2431a3f5483919319eff181a09618fc7R3060 would you prefer to just take a look at that code w/o finishing this PR? |
You mean without merging this PR? Sure, that makes sense, I can do that. |
I'm happy to clean up this PR and get it merged, I think it's pretty much ready to go, just whatever you'd prefer to do :) |
Is there anything in this PR that seems like it should be changed? maybe it's actually ready to go right now? |
So I was just looking and was curious if any tests would be failing. So I did a lot of changes to the way the colors are parsed, but looking at your changes it all seems contained within the _trisurf backend functions. So yeah, I guess we should merge |
Ok, let's do it! |
I have to run now, but feel free to do it. Thanks for all the help! |
I don't think I have privileges to do any merging, so it'll have to be a plotly person |
@theengineear Andrew, can I get the green light on doing this? |
Ya, merge away guys! I was offline for a few days, sorry for the delay! 💃 |
@Kully probably better to make a pr so we can check out why the |
… test in trisurf for data[2] since colorbar came after Chris' trisurf optimization commits
This is a quick extension of #493. There was a lot of talk about the best way to interpolate between multiple colors in a readable, quick way. This PR mostly does 2 things:
LinearSegmentedColormap
. This is a way of creating a custom cmap from a list of rgb colors. Then you can pass it any value between 0 and 1 and it'll return the RGB value. Should have the exact same functionality, is vectorized, and means that some extra code can be removed.Only drawback I can see is that it introduces another dependency on matplotlib, but it seems like this is already depended on elsewhere, and besides it's likely that the majority of python plotly users will have this installed. LMKWYT.