pyplot转3d pdf [英] pyplot to 3d pdf

查看:49
本文介绍了pyplot转3d pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何保存3d pyplot图像,以便仍可以在pdf查看器中旋转它?我知道可以保存pdf以便旋转3d图像(我以前有这样的文件)-如何使用pyplot完成此操作?这个问题的动机是我想分享其他人可以旋转的图像 - 我在 python 查看器中旋转图像,拍摄 2d 快照是不够的.

How can I save a 3d pyplot image so that I can still rotate it in my pdf viewer? I know pdfs can be saved so that the 3d image can be rotated (I've had files like this before) - how can I accomplish this using pyplot? The motivation for this question is that I want to share images which others can rotate - it is not sufficient for me to rotate the image in the python viewer, taking 2d snapshots.

这是我的示例代码.我无法在生成的 pdf 中旋转图像.

Here is my example code. I cannot rotate the image in the pdf which this generates.

import numpy as np
from matplotlib import pyplot as plt
from scipy.interpolate import griddata
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')

X = np.random.random(1000)
Y = np.random.random(1000)
Z = np.random.random(1000)

xi = np.linspace(X.min(),X.max(),100)
yi = np.linspace(Y.min(),Y.max(),100)

zi = griddata((X, Y), Z, (xi[None,:], yi[:,None]), method='cubic')

ax = fig.add_subplot(111, projection='3d')

xig, yig = np.meshgrid(xi, yi)

surf = ax.plot_surface(xig, yig, zi,linewidth=0)

plt.savefig('/Users/kilojoules/Downloads/ex.pdf')

推荐答案

3D PDF 文件具有称为 3D 注释的内部结构,可以包含通用 3D (U3D) 或 PRC 格式的 3D 模型.如果您的 PDF 文件有 3D 注释,您可以在 3D 中查看/旋转/标记.有许多公司(例如www.dimensionpdf.com)制造工具,可以从流行的CAD软件包(例如AutoCAD)创建3D PDF文件.

3D PDF files have an internal structure called a 3D annotation that can contain a 3D model in the Universal 3D (U3D) or PRC format. If your PDF file has a 3D annotation, you can view/rotate/markup in 3D. There are a number of companies (such as www.dimensionpdf.com) that make tools for creating 3D PDF files from popular CAD packages (like AutoCAD).

如果无法旋转3D模型,则PDF最有可能仅包含3D模型的2D图像,而不是3D注释.

If you cannot rotate the 3D model, then the PDF most likely contains just a 2D image of a 3D model, rather than a 3D annotation.

这篇关于pyplot转3d pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆