python - 如何将 Matplotlib 交互式 3D 绘图导出为无需 Python 即可打开的格式(例如 HTML)?
问题描述
我想向非 python 用户发送 Matplotlib 交互式 3D 图,以便他们可以旋转和放大/缩小图形。例如,下面的代码会生成一个简单的 3D 条形图,但如果没有安装 Python,则无法读取。
我尝试使用 mpld3 函数(get TypeError: Object of type ndarray is not JSON serializable)使用 PyInstaller 编译并读取 pickle.dumb 文件(未显示图),使用上一个线程中建议的 libscript 模块(保存交互式 Matplotlib 数字)没有成功。
''''
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
xpos = [1,2,3,4,5,6,7,8,9,10]
ypos = [2,3,4,5,1,6,2,1,7,2]
zpos = [0,0,0,0,0,0,0,0,0,0]
dx = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
dy = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
dz = [1,2,3,4,5,6,7,8,9,10]
ax1.bar3d(xpos, ypos,zpos, dx, dy, dz, color = '#00ceaa')
plt.show()
''''
解决方案
推荐阅读
- machine-learning - 神经网络分类成层次类别
- android - 无法使用 Retrofit 通过 POST 发送数据?
- scheme - 使用define和let in方案的主要区别
- c++ - 我可以在 C++20 的类型别名中使用条件吗?
- r - 试图理解 R 中的 cdplot
- python - 来自防病毒软件的 Python 错误检测
- spring-security - Keycloak spring boot 适配器不检查授权标头以获取有效的访问令牌
- javascript - 在父组件 React 中显示按钮信息
- android - 按钮动画(带有 ClipDrawable 的 TimeAnimator)无法正常工作
- c++ - OpenMP:容器的模板化自定义缩减(特征类型)