# Is there a way to export a 3D contour plot (contour lines only) to a vector format?

I have a function defined on a 3D surface, which I wish to plot as a contour plot, and export to a vector graphics format. Based on this question and various others, it seems that there is generically no way to do this for 3D plots (unless something has been introduced since v10). I tried RegionPlot and ParametricPlot3D with MeshFunctions, etc, but they all export raster graphics.

However, is there some hack to make it work for a function where I only wish to export the contour lines themselves (i.e. no shading or gradients) on the surface of a sphere? In 2D, it's possible to nicely simplify the plotted lines as in the solutions to this question, so can something like this somehow be generalised to lines on the surface of a sphere? Or is it strictly only 2D graphics that are supported for vector output?

Edit

A (simplified) example of the sort of plot I mean:

ParametricPlot3D[{Sin[\[Theta]] Sin[\[Phi]],
Cos[\[Phi]] Sin[\[Theta]], Cos[\[Theta]]}, {\[Theta],
0, \[Pi]}, {\[Phi], 0, 2 \[Pi]},
MeshFunctions -> {{x, y, z, \[Theta], \[Phi], r} |->
Sin[2 \[Theta]] Cos[\[Phi]]}, PlotStyle -> Opacity[0],
MeshStyle -> Thickness[Medium]]


• Contour surfaces or contour lines? An example showing something to be exported would help. Nov 7, 2022 at 12:18
• just the contour lines, over a simple 3D surface Nov 7, 2022 at 12:29
• Yes, now we can only use Mathematica 9.0 to export 2D vector format pdf file. Nov 7, 2022 at 12:37

Or project to 2D plane and export to 2D vector format pdf.

plot = ParametricPlot3D[{Sin[θ] Sin[ϕ],
Cos[ϕ] Sin[θ], Cos[θ]}, {θ,
0, π}, {ϕ, 0, 2 π},
MeshFunctions ->
Function[{x, y, z, θ, ϕ, r},
Sin[2 θ] Cos[ϕ]], PlotStyle -> Opacity[0],
MeshStyle -> Thickness[Medium], PlotPoints -> 80,
MaxRecursion -> 4, Axes -> False, ViewProjection -> "Orthographic",
ViewPoint -> {1, 1, 1}, Boxed -> False];
twodimplot =
Graphics[
plot[[1]] /. {x_Real, y_Real, z_Real} ->
Most[RotationMatrix[{{0, 0, 1}, {1, 1, 1}}] . {x, y, z}]];
Export["test.pdf", twodimplot]
SystemOpen["test.pdf"]


Is a Tube okay?

foo = ParametricPlot3D[{Sin[\[Theta]] Sin[\[Phi]],
Cos[\[Phi]] Sin[\[Theta]], Cos[\[Theta]]}, {\[Theta],
0, \[Pi]}, {\[Phi], 0, 2 \[Pi]},
MeshFunctions -> {{x, y, z, \[Theta], \[Phi], r} |->
Sin[2 \[Theta]] Cos[\[Phi]]}, PlotStyle -> Opacity[0],
MeshStyle -> Tube[0.02]]
Export["/tmp/foo.svg", foo]