# Save 3d plot as vector format

 1 Is there a way to export a 3d plot as a pdf file? I know you can't do p.save('filename.extension') because 3dplot doesn't create a graphics item. But is there a way to do this? asked Jun 10 '12 daniel.e2718 61 ● 1 ● 3 ● 10

 5 The Sage 3D plots don't support output in a 2D vector format (like PDF), at least not for now. You can do it by calling matplotlib directly: PDF version of the image below from mpl_toolkits.mplot3d import axes3d from mpl_toolkits.mplot3d.art3d import Poly3DCollection import matplotlib.pyplot as plt import numpy as np from matplotlib import rc rc('text', usetex=True) rays = [(-3, -2, 4), (0, 1, 0), (1, 0, 0), (2, 1, -4)] extrapoints = [(-1, -1, 2), (1, 1, -2)] cones = [[0,1,2],[0,1,3],[0,2,3],[1,2,3]] poly3d = [] for cone in cones: verts = [ rays[i] for i in cone ] poly3d.append(verts) polygons = Poly3DCollection(poly3d, facecolor='green', linewidths=2, alpha=0.1) polygons.set_alpha(0.3) fig = plt.figure() fig.set_figwidth(13.0/2.54) fig.set_figheight(9.0/2.54) ax = axes3d.Axes3D(fig) ax.scatter3D(*zip(*rays), s=50, c='red') ax.scatter3D(*zip(*extrapoints), s=50, c='blue') ax.scatter3D([0],[0],[0], s=20, c='black') ax.add_collection3d(polygons) ax.set_xlabel(r'$X$') ax.set_ylabel(r'$Y$') ax.set_zlabel(r'$Z$') ax.set_xlim3d(-3, 2) ax.set_ylim3d(-2, 1) ax.set_zlim3d(-4, 4) r = rays[0] ax.text(r[0]-0.2,r[1],r[2], r'${}^{'+str(r)+'}$', horizontalalignment='right', verticalalignment='top', color='red') r = rays[3] ax.text(r[0]-0.2,r[1],r[2], r'${}^{'+str(r)+'}$', horizontalalignment='right', verticalalignment='top', color='red') r = rays[1] ax.text(r[0],r[1],r[2]+0.3, r'${}^{'+str(r)+'}$', horizontalalignment='center', verticalalignment='bottom', color='red') r = rays[2] ax.text(r[0],r[1],r[2]-0.3, r'${}^{'+str(r)+'}$', horizontalalignment='center', verticalalignment='top', color='red') r = extrapoints[0] ax.text(r[0],r[1],r[2]-0.3, r'${}^{'+str(r)+'}$', horizontalalignment='center', verticalalignment='top', color='blue') r = extrapoints[1] ax.text(r[0]+0.2,r[1],r[2], r'${}^{'+str(r)+'}$', horizontalalignment='left', verticalalignment='bottom', color='blue') ax.text(-0.2,0,0, r'${}^0$', horizontalalignment='right', verticalalignment='top', color='black') # plt.show() for axis in [ax.w_xaxis, ax.w_yaxis, ax.w_zaxis]: axis.get_major_locator()._integer = True for t in axis.get_ticklabels(): t.set_fontsize(6) plt.savefig('fig_NablaBsing.pdf', bbox_inches='tight')  posted Jun 11 '12 Volker Braun 2666 ● 9 ● 24 ● 59 That response made me think curse words. Seems like a lot of work for one picture.daniel.e2718 (Jun 20 '12)
 1 I don't think the 3d plots support output to a PDF. I have gotten a TIFF, however, and then converted it to a PDF. You can also use the viewer='tachyon' option and get a TIFF (but not a PDF). posted Jun 10 '12 calc314 2200 ● 7 ● 25 ● 62
 0 Another option that might work is a screen capture to a PDF, although it's not an elegant solution. This has the advantage of letting you turn the 3D graphic to the viewpoint that you'd like and then getting the image. To do that otherwise requires some dancing using Tachyon commands, as I understand it. posted Jun 11 '12 calc314 2200 ● 7 ● 25 ● 62

[hide preview]