1.源码实现
using CairoMakie
using LaTeXStrings
θ = deg2rad(225)
s = 0.5
Lx, Ly, Lz = s*0.8, s*1.0, s*1.0
ex = (Lx*cos(θ), Lx*sin(θ)); ey = (Ly, 0.0); ez = (0.0, Lz)
fig = Figure(size = (600, 600), backgroundcolor = :white)
ax = Axis(fig[1, 1];
aspect = DataAspect(),
limits = (-1.1, 1.1, -1.1, 1.1), # ← limits 也同步收小
xticks = (Float64[], String[]), yticks = (Float64[], String[]),
xgridvisible = false, ygridvisible = false,
leftspinevisible = false, rightspinevisible = false,
bottomspinevisible = false, topspinevisible = false,
backgroundcolor = :white
)
# ---- xOy 平面:平行四边形(同样乘 s)----
ux = (cos(θ), sin(θ)); uy = (1.0, 0.0)
ax_ = s * 1.00
ay_ = s * 1.25
P1 = ( ax_*ux[1] + ay_*uy[1], ax_*ux[2] + ay_*uy[2])
P2 = ( ax_*ux[1] - ay_*uy[1], ax_*ux[2] - ay_*uy[2])
P3 = (-ax_*ux[1] - ay_*uy[1], -ax_*ux[2] - ay_*uy[2])
P4 = (-ax_*ux[1] + ay_*uy[1], -ax_*ux[2] + ay_*uy[2])
xs = [P1[1], P2[1], P3[1], P4[1], P1[1]]
ys = [P1[2], P2[2], P3[2], P4[2], P1[2]]
lines!(ax, xs, ys; color = (:black, 0.7), linewidth = 1.2)
# ---- 轴线 ----
for (e, name, off) in ((ex, L"$x$", (-0.05*s, -0.05*s)),
(ey, L"$y$", ( 0.02*s, -0.06*s)),
(ez, L"$z$", (-0.10*s, -0.03*s)))
arrows2d!(ax, [0.0], [0.0], [e[1]], [e[2]];
shaftcolor = :black, shaftwidth = 2,
tipcolor = :black, tipwidth = 14, tiplength = 18)
text!(ax, e[1] + off[1], e[2] + off[2];
text = name, fontsize = 26, color = :black,
align = (:center, :center)
)
end
scatter!(ax, [0.0], [0.0]; color = :black, markersize = 8, marker = :circle)
text!(ax, 0.02, -0.12*s; text = L"$O$", fontsize = 24,
color = :black, align = (:center, :center)
)
save("axes3d_plane.png", fig; px_per_unit = 2)
2.结果展示

axes3d_plane.png