# How to simplify the plot codes or provide a new method to obtain the ideal PDF?

I want to create two planes in 3D space (looks like the following figure 1). Firstly, I try to use the ContourPlot3D and Polygon, but both of them will generate some unexpected grid or triangle (looks like the following figure 2) when "save as" or "export" the planes to PDF, so I have to replace these two function with Line (looks like the following figure 3), but the codes are long and complicate. Later, I find these codes are regular, so want to simplify them, but this is difficult for me. Hope you can help me simplify the plot codes or provide a new method to obtain the ideal PDF, Note: I want to have a 3D vector graphics(PDF is better). Thanks.

The parameters of these lines are regular, which looks like the following:

x = 0;
y = 10;
Graphics3D[{
Thickness[0.002], Black, Line[{{x, -y, 0}, {x, y, 0}}],
Thickness[0.002], Black, Line[{{x, -y, 80}, {x, y, 80}}],
Thickness[0.002], Black, Line[{{x, y, 0}, {x, y, 80}}],
Thickness[0.002], Black, Line[{{x, -y, 0}, {x, -y, 80}}],
Thickness[0.002], Black, Line[{{-y, x, 0}, {y, x, 0}}],
Thickness[0.002], Black, Line[{{-y, x, 80}, {y, x, 80}}],
Thickness[0.002], Black, Line[{{y, x, 0}, {y, x, 80}}],
Thickness[0.002], Black, Line[{{-y, x, 0}, {-y, x, 80}}]
}, BoxRatios -> {1, 1, 1}]


How to simplify them. Thanks!

Here are the codes of other two functions

sx = 10;
ContourPlot3D[{{x == 0}, {y == 0}}, {x, -sx, sx}, {y, -sx, sx}, {z, 0,
80}, Mesh -> None,
ContourStyle -> {Directive[Blue, Opacity[0.01]],
Directive[Red, Opacity[0.01]]}, PlotRange -> All]

Graphics3D[{Thickness[0.002], Black, Line[{{0, 0, 0}, {0, 0, 80}}],
Blue, Opacity[.1],
Polygon[{{-sx, 0, 0}, {sx, 0, 0}, {sx, 0, 80}, {-sx, 0, 80}}], Red,
Opacity[.1],
Polygon[{{0, -sx, 0}, {0, sx, 0}, {0, sx, 80}, {0, -sx, 80}}]},
BoxRatios -> {1, 1, 1}]


Figure 1

Figure 2

Figure 3

• The question is unclear to me. What's the input here? What are f and expr? Are you looking for something like func[x_, y_]={{x, y, 30}, {-x, -y, 30}, {y, x, 30}, {-y, -x, 30}}; func[1, 2]? – xzczd Jul 19 '20 at 6:01
• OK, so you've over-simplified the question. Then, have you tried Hyperplane or InfinitePlane? – xzczd Jul 19 '20 at 7:43
• @xzczd, the two functions you mentioned are introduced after the Mathematica version 10, however, they can not "save as" or "export" 3D vector graphics after the version 9.0. Can you provide me another solution? Thanks. – likehust Jul 19 '20 at 7:56
• …Do you mean you're in v9? If so, please mention this in the question. – xzczd Jul 19 '20 at 8:01
• Just tested in v9, Win10, the following works well: Export["a.pdf", ContourPlot3D[{x == 0, y == 0}, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, Mesh -> None, ContourStyle -> Opacity[0.1], Ticks -> None]] // SystemOpen I guess you didn't add Mesh->None? – xzczd Jul 19 '20 at 8:07

How about AnglePath?:

pts = AnglePath[{1/2, -1/2}, Table[90 °, 4]];

{{#, 0, #2} & @@@ pts, {0, #, #2} & @@@ pts} // Line // Graphics3D


Since there's a design change for export of Graphics3D[…] to PDF format after v9 and it seems to be hard to bring back the old behavior in newer versions, I think the easiest work-around is to stay in v9 and implement AnglePath ourselves. Luckily J.M. has already implemented it here. So we just need to modify the code to:

pts = anglePath[{1/2, -1/2}, Table[90 °, {4}]];

{{#, 0, #2} & @@@ pts, {0, #, #2} & @@@ pts} // Line // Graphics3D


Notice I've modified the syntax of Table, you may check this post for more info about the syntax change.

• Thanks. It's become concise exactly, but if you noticed that it fails to generate vector graphics. – likehust Jul 20 '20 at 1:45
• @likehust Then I believe your approach won't generate vector graphics, either, because it's a combination of Graphics3D and Line, just like mine. Can you clarify the meaning of "vector graphics" in your mind? – xzczd Jul 20 '20 at 3:24
• Thanks for your reply. the vector graphics I want is same as here, the AnglePath is introduced on version 10, so it can not "save as" or "export" to a 3D vector graphics(but can generate 2D vector graphics), and I have tested the result. – likehust Jul 20 '20 at 3:49
• @likehust "the AnglePath is introduced on version 10, so it can not "save as" or "export" to a 3D vector graphics(but can generate 2D vector graphics" I don't understand what you mean. The output of AnglePath is just a list of numbers whose dimension is $n×2$, and I've transformed it to a $n×3$ list with {#, 0, #2} & @@@. The output of my code is undoubtedly 3D vector grahpic. Have you tried my code? – xzczd Jul 20 '20 at 4:15
• From V10, the exported 3D PDF graphics are bitmaps, but 2D PDF graphics are vectors. Maybe the V9 is the final version that can "save graphic as" and "export" 3D and 2D PDF vector graphics at the same time. So, AnglePath , introduced on V10.1 in 2015, can not generate 3D PDF vector graphics, it only can obtain bitmap figure when export or save graphic as. I have tested your code, thanks. – likehust Jul 20 '20 at 7:38
f[x_, y_] := {{x, y, 30}, {-x, -y, 30}, {y, x, 30}, {-y, -x, 30}}

x = 1;
y = 2;

Apply[f, List[x, y]]


{{1, 2, 30}, {-1, -2, 30}, {2, 1, 30}, {-2, -1, 30}}

• Sorry, I didn't propose a clear question. But, you can proceed to give a better solution. Thanks. – likehust Jul 19 '20 at 7:58