1 | initial version |
I don't know how to do texture maps, although it might be possible (see, e.g., this question about color maps). But you might be able to work around this if you can write your graph as a parametrized curve or union thereof. Then just compose with the parametrizing functions for the torus and plot! Here's an example that I was working on for something else but seems useful here :)
# Parametric equations for a torus; the fundamental domain is the square [0,2*pi] x [0,2*pi]
sage: var('u,v');
sage: a,b = 2,1 # outer and inner radii
sage: x = (a + b*cos(u))*cos(v)
sage: y = (a + b*cos(u))*sin(v)
sage: z = b*sin(u)
# A parametric curve (line) in the u-v plane
sage: var('t');
sage: c = (2*t,3*t)
sage: # the same curve in cartesian coordinates on the torus
sage: s = [_.subs(dict(zip((u,v),c))) for _ in (x,y,z)]
sage: s
[(cos(2*t) + 2)*cos(3*t), (cos(2*t) + 2)*sin(3*t), sin(2*t)]
sage: curve = parametric_plot(s,(t,0,2*pi),color='red',thickness=2,plot_points=400)
sage: T = parametric_plot3d([x,y,z], (u,0,2*pi),(v,0,2*pi), opacity=.6,aspect_ratio=1)
sage: T+curve
And here's a slightly fancier example with more curves:
sage: plane_curves = [(i*2*pi/5 + 2*t,3*t) for i in range(5)]+[(i*2*pi/5 + 3*t,-2*t) for i in range(5)]
sage: torus_curves = [[_.subs(dict(zip((u,v),c))) for _ in (x,y,z)] for c in plane_curves]
sage: curve_plots = [parametric_plot(torus_curves[i], (t,0,2*pi), color=hue(2*i/10), thickness=4, plot_points=400) for i in range(10)]
sage: from sage.plot.plot3d.base import Graphics3d # initial term for sum below
sage: T + sum(curve_plots,Graphics3d())