简体   繁体   English

plt.show() 不显示 3d 散点图

[英]plt.show() does not show the 3d scatter image

community,社区,

I tried to create the 3d scatter by using matplotlib Axes3D on jupyter notebook.我尝试在 jupyter notebook 上使用 matplotlib Axes3D 创建 3d 散射。 However, it is not showing the image once I execute 'plt.show()'.但是,一旦我执行“plt.show()”,它就不会显示图像。

#pip install matplotlib
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.figure()
ax =fig.add_subplot(111, projection = '3d')
x = dframe['CTR']
y = dframe['Clicks']
z = dframe['Avg. CPC']
ax.scatter(x, y, z, c='r', marker='o')
plt.show()

Your code works fine like this:您的代码工作正常,如下所示:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")

# dummy data (your actual data should go here)
x = [1, 2, 3, 4]
y = x
z = x
ax.scatter(x, y, z, c="r", marker="o")
plt.show()

This shows:由此可见:

在此处输入图片说明

May be something is wrong with your data.可能是您的数据有问题。 Also, since you are using plt.show() anyway, you can remove the %matplotlib inline line.此外,由于您无论如何都在使用plt.show() ,因此您可以删除%matplotlib inline行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM