Closed rythorpe closed 3 months ago
Fix is welcome !
I don't think there is a way to update an 2d axis to a 3d projection. https://stackoverflow.com/questions/35209489/can-i-turn-an-existing-ax-object-into-a-3d-projection
Maybe there should be a check on an axes argument and raises an error if it's not a Axes3D object?
I was thinking of removing the existing 2D axes and then adding new 3D axes, but this might mess with formatting if the user starts with a more detailed grid of subplots (maybe?). Your suggestion about adding a check for an Axes3D object is probably the easiest solution, however.
In that case I think the user would have to pass the grid/subplot/figure so you can index which one to replace. I don't think it's typical convention to pass the whole axes array to a plotting function.
I believe the figure as accessible via Axes.get_figure()
, but I generally agree that the simpler solution where we raise an error if the user attempts plotting on the wrong type of Axes object is the way to go.
as long as we catch the error before it becomes a cryptic traceback, I think it's fine
Hey @rythorpe , can I take this issue, Can you confirm that we just need to check if ax
is not an instance of Axes3D
and then raise a TypeError
?
Yep, go for it @samadpls!
Found by @wagdy88.
If you create a figure with multiple subplots and then pass one of those subplots into
plot_cells()
(as can be done for most plotting functions inviz.py
), an error is thrown.For example, running
produces the following:
I'm pretty sure the issue here is that Matplotlib is trying to project a 3D plot onto a 2D Axes instance, however, this can be confusing to users who aren't familiar with using Matplotlib to plot in 3D. I suggest that we either come up with a patch within
plot_cells
that converts the Axes projection from 2D to 3D (thus allowing the user to pass in any generic Axes object and have it work) or remove theax
parameter fromplot_cells
altogether to remove confusion.