python - 如何在 python 中绘制基于散点图的 2 x 2 三维图,以使它们均匀分布在图中?
问题描述
这些是我使用 matplotlib 绘制图形的配置
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax_tl = fig.add_subplot(211, projection='3d')
ax_br = fig.add_subplot(221, projection='3d')
ax_Y0 = fig.add_subplot(212, projection='3d')
ax_Y1 = fig.add_subplot(222, projection='3d')
我尝试了第一个参数的许多不同组合,并从该文档fig.add_plot()
中汲取了灵感。
我目前正在考虑将它们分开绘制,如果它不值得麻烦的话。
所以问题是,如何在 python 中绘制基于散点图的 2 x 2 三维图形,以使它们均匀分布在图形中?我当前的代码使情节挤在一起
解决方案
这应该做你想要的:
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
spec = gridspec.GridSpec(ncols=2, nrows=2, figure=fig)
ax_tl = fig.add_subplot(spec[0, 0], projection='3d')
ax_br = fig.add_subplot(spec[0, 1], projection='3d')
ax_Y0 = fig.add_subplot(spec[1, 0], projection='3d')
ax_Y1 = fig.add_subplot(spec[1, 1], projection='3d')
推荐阅读
- javascript - 如何在更改屏幕尺寸等时让我的 Web 应用程序响应更快?
- optimization - 确定为什么visual studio优化了一个功能?
- javascript - 打字时的 DOM 操作在 iPad 上不起作用但在 iPhone 上起作用
- google-cloud-platform - 安全的 Cloud Run 服务仅接受来自浏览器中域的请求(而不是 Postman / shell 脚本)
- python - 必须为多个窗口重复按下 Tkinter 的“退出”按钮
- apache-flink - flink作业将数据写入hdfs文件时是否可以每小时执行一次分区添加?
- youtube - Youtube 永久直播网址
- java - 如何使用 Selenium 和 Java 向用户名字段发送文本
- python - 迁移学习时的批量标准化
- python - 当我在按下按钮时调用 pyqt5 中的方法时,如何从方法中捕获异常