python-2.7 - Python-一个窗口中有多个3D图

标签 python-2.7 matplotlib

有没有一种方法可以在一个窗口中绘制多个图(图形以qt显示)?

最佳答案

当然。

关键字是子图。阅读this以获得基本概述。

看看这个官方示例from here:

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


# imports specific to the plots in this example
import numpy as np
from matplotlib import cm
from mpl_toolkits.mplot3d.axes3d import get_test_data

# Twice as wide as it is tall.
fig = plt.figure(figsize=plt.figaspect(0.5))

#---- First subplot
ax = fig.add_subplot(1, 2, 1, projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
                       linewidth=0, antialiased=False)
ax.set_zlim3d(-1.01, 1.01)

fig.colorbar(surf, shrink=0.5, aspect=10)

#---- Second subplot
ax = fig.add_subplot(1, 2, 2, projection='3d')
X, Y, Z = get_test_data(0.05)
ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)

plt.show()

输出

enter image description here

关于python-2.7 - Python-一个窗口中有多个3D图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39616547/

相关文章:

python - 如何使用给定坐标在图像中绘制一个点

python - 使图例对应于matplotlib中散点的颜色

python - 如何使用 PyQt Signal Slot 连接两个类?

python - 这个打印语法是什么? (打印右移)

python - 谷歌Foobar L4 : Bringing a gun to a trainer fight

python - 文本小部件内 Tkinter 中的滚动条

python - 如何在 lambda 函数中执行赋值

python - 如何消除matplotlib Axis 的相对偏移

python - 使用 matplotlib 绘制 SQL (MariaDB) 中的表值

python - 如何在 matplotlib 中只显示左边框和下边框?