Reputation: 650
I am trying to create a 3D scatter plot using matplotlib in a Jupyter Notebook page. The code is not returning any errors, but I have yet to have the plot actually show up. The output is just blank.
Python: 3.7.3 Matplotlib: 3.0.3
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib inline
%matplotlib notebook
threedee = plt.figure().gca(projection='3d')
threedee.scatter(existing_df_2d.PC1, existing_df_2d.PC2,
existing_df_2d.data_mean)
plt.show()
I included an example of the output (it's blank):
Upvotes: 3
Views: 1789
Reputation: 39072
You are using two backends
%matplotlib inline
%matplotlib notebook
As a result, there seems to be a conflict between the two backends when invoked in parallel one after the other.
P.S: When I tried putting %matplotlib notebook
in the same cell as the rest of the code, I did not see any figure. When I put it in a different cell, I see the figure.
Solution: Just use either the %matplotlib inline
or %matplotlib notebook
in a new separate cell and things will work fine
Upvotes: 2
Reputation: 12948
In my experience, %matplotlib notebook
doesn't work with 3D plots unfortunately. Just use %matplotlib inline
and you should be OK.
Upvotes: -1