-
Notifications
You must be signed in to change notification settings - Fork 20
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
3D plots #89
Comments
Hey @ianhi, this would indeed be cool to have! I wrote a small example of how to do this with both matplotlib widgets and ipywidgets here. Now the challenge is to think of a general way of implementing this in I might get back to that later (would need time to dive through the codebase to think of an interface that matches the existing ones), but I thought in the meantime I'd post a link to that little demo. Perhaps you have feedback to the snippets there? I'm not that familiar yet with both of the widget interfaces. |
@redeboer I have seen this and love that you're interested! Bit busy at the moment but will try to respond soon (please fell free to ping me if this slips away though) |
This shouldn't be too hard! The hard part is always figuring out a good way to update the matplotlib artist (this is super inconsistent across the library) I wrote up how to integrate with mpl-interactions here: #180
1st they look nice - as do your docs. They're also a reasonable way to make an animation. However, there are two downsides to your approach.
For example to animate a line you use the I think that this is generally the preferred way to animate matplotlib artists (matplotlib/matplotlib#19520). However not every plotting function returns an object with an easy Methods without set_data generallyI've been hesitant to add any functions that don't have artist = ax.plot_surface(...)`
def update(params, indices, cache):
nonlocal artist
artist.remove()
X = callable_else_value(X, params, cache)
artist = ax.plot_surface(...)
controls._register_function(update)
|
Thanks a lot for your thorough explanation! It's valuable that you document things so well in these issues and pull requests 👍 I indeed read that most 3D objects do not have a I'll gladly work on your PR #201, particularly writing some documentation. It seems like it will be hard to get a nice implementation given mpl's 3D interfaces, but if the interfaces I have to say, btw, that I quite liked the idea of those |
Yeah those are pretty slick. Do note though there are a few ways in which I think they are not optimal for plotting due how they interact with the widget backend and also different semantics for specifying how sliders are created. (e.g. mpl-interactions uses If you have any suggestions for a way |
Hey @redeboer, ian helped me throw this together the last time i wanted to animate a 3d scatter plot, might be helpful for you. T = 100
N = 50
data = np.random.randn(T,N,3)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
X, Y, Z = data[0].T
scatter = ax.scatter(X,Y,Z)
slider = widgets.IntSlider(val=0, min=0, max =T-1)
def update3d(change):
X, Y, Z = data[slider.value].T
scatter._offsets3d = (X,Y,Z)
scatter.set_color(...)
slider.observe(update3d, names='value') |
Thanks @jrussell25! I could also write a note on |
This would be dope and at least one perosn has desired this in the past: https://discourse.matplotlib.org/t/how-to-plot-a-dynamic-3d-graph-using-matplotlib/21431
I think that for sanity sake these should get their own
interactive_plot3D
and associated factory functionTagging as help wanted because I have no plans to implementing this in the near future
The text was updated successfully, but these errors were encountered: