1 | initial version |
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')