3D散点图显示为黑色窗口。

huangapple go评论59阅读模式
英文:

3d scatter plot is displaying a black window

问题

这是一个Matplotlib在我的本地环境上显示黑色窗口的示例。

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

fig = plt.figure()
ax = Axes3D(fig, elev=4, azim=-95)
xs, ys, zs = np.linspace(-2, 2, 60), np.linspace(-2, 2, 60), np.linspace(-2, 2, 60)
ax.scatter(xs=xs, ys=xs, zs=xs)
plt.show()

我知道问题不是出现在我的后端,因为其他人已经报告过类似的问题,我可以在这个网站上正常运行这段代码:

https://matplotlib.org/2.0.2/examples/mplot3d/subplot3d_demo.html

英文:

Here is an example of matplotlib displaying a black window on my local environment.

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

fig = plt.figure()
ax = Axes3D(fig, elev=4, azim=-95)
xs, ys, zs = np.linspace(-2, 2, 60), np.linspace(-2, 2, 60), np.linspace(-2, 2, 60)
ax.scatter(xs=xs, ys=xs, zs=xs)
plt.show()

I know the issue is not my backend as others have reported, since I can run the snippet at this site fine:

https://matplotlib.org/2.0.2/examples/mplot3d/subplot3d_demo.html

答案1

得分: 1

  • ax = fig.add_subplot(projection='3d', elev=4, azim=-95) 不要 ax = Axes3D(fig, elev=4, azim=-95),就像 示例 中显示的那样。
  • python 3.11.3matplotlib 3.7.1 中测试过
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(projection='3d', elev=4, azim=-95)

xs, ys, zs = np.linspace(-2, 2, 60), np.linspace(-2, 2, 60), np.linspace(-2, 2, 60)
ax.scatter(xs=xs, ys=xs, zs=xs)
plt.show()

3D散点图显示为黑色窗口。

英文:
  • ax = fig.add_subplot(projection='3d', elev=4, azim=-95) not ax = Axes3D(fig, elev=4, azim=-95), just like it shows in the example.
  • Tested in python 3.11.3, matplotlib 3.7.1
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(projection='3d', elev=4, azim=-95)

xs, ys, zs = np.linspace(-2, 2, 60), np.linspace(-2, 2, 60), np.linspace(-2, 2, 60)
ax.scatter(xs=xs, ys=xs, zs=xs)
plt.show()

3D散点图显示为黑色窗口。

huangapple
  • 本文由 发表于 2023年5月29日 08:51:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76354125.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定