I can’t find out how to get data from an mplot3d graph. Something similar to the 2D style:
line.get_xdata()
Is it possible?
I can’t find out how to get data from an mplot3d graph. Something similar to the 2D style:
line.get_xdata()
Is it possible?
This issue was filed on Github and there is contribution that adds new
get_data_3d
andset_data_3d
methods. Unfortunately, these changes is likely not yet available in distributions. So you might have to continue using private variableline._verts3d
.See more here: https://github.com/matplotlib/matplotlib/issues/8914
Line3D
You can get get the original data from the (private)
_verts3d
attributeComplete example
Some explanation: The problem with
get_data
orget_xdata
is that it will return the projected coordinates once the figure is drawn. So while before drawing the figure,line.get_xdata()
would indeed return the correct values, after drawing, it would return something likein the above example, which is the x component of the 3D coordinates projected onto 2D.
There is a pull request to matplotlib, which would allow to get the data via methods
get_data_3d
. This is still not merged, but might allow the above to be done without using private arguments in a future version of matplotlib.Poly3DCollection
For a
plot_surface
plot this looks similar, except that the attribute to look at is the._vec