我想用 PSTricks 或者 tikz 画一个中心复合设计。这是下面显示的带有轴的立方体。我试过 pst-3d,但这并不容易。如果你有一个类似图形的例子,那就太理想了。
编辑(稍后):好吧,我回到家了,我抽出一些时间用 pst3d-plot 做了这个图。这不是最终的图,但现在可以借助pst3d-plot 文档(除了选项并未全部记录下来,例如pstThreeDBox
- 您知道其他文档吗?)
\documentclass[12pt]{article}
\usepackage{pst-all}
\usepackage{pst-3dplot}
\begin{document}
\begin{pspicture}(-6,-6.5)(6 ,6)
\psset{Alpha=30,Beta=20}
\pstThreeDBox[fillstyle=gradient,RotSequence=xyz](-4,-4,-4)(0,8,0)(8,0,0)(0,0,8)
\pstThreeDDot(6.7,0,0)
\pstThreeDDot(0,6.7,0)
\pstThreeDDot(0,0,6.7)
\pstThreeDCoor[linecolor=black, IIIDticks, IIIDlabels,
IIIDOffset={(0,0,0)},
xMin=-7.95, yMin=-7.95, zMin=-7.95,
xMax=8, yMax=8, zMax=8,
IIIDxTicksPlane=xz, IIIDxticksep = 0.4, , Dx=1, deltax=4,
IIIDyTicksPlane=xz, IIIDyticksep = -0.4, , Dy=1, deltay=4,
IIIDzTicksPlane=xz, IIIDzticksep = -0.4, , Dz=1, deltaz=4]
\end{pspicture}
\end{document}
答案1
也许您可以使用此tikz
代码作为起点:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,3d}
\begin{document}
\begin{tikzpicture}[x = {(-0.5cm,-0.5cm)},
y = {(0.95cm,-0.25cm)},
z = {(0cm,1cm)}]
\begin{scope}[canvas is yz plane at x=-1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle ;
\foreach \x in {-1,1}
\foreach \y in {-1,1}
\fill[blue] (\x,\y) circle (1pt);
\end{scope}
\begin{scope}[canvas is yz plane at x=1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
\foreach \x in {-1,1}
\foreach \y in {-1,1}
\fill[blue] (\x,\y) circle (1pt);
\end{scope}
\begin{scope}[canvas is xz plane at y=1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
\end{scope}
\begin{scope}[canvas is xz plane at y=-1]
\draw[blue] (-1,-1) -- (-1,1) -- (1,1) -- (1,-1) -- cycle;
\end{scope}
\begin{scope}[canvas is yz plane at x=0]
\draw[red,dashed] (-1.5,0) -- (0,0) -- (1.5,0);
\draw[red,dashed] (0,-1.5) -- (0,0) -- (0,1.5);
\foreach \y in {-1.5,0,1.5} \fill[blue] (\y,0) circle (1pt);
\foreach \z in {-1.5,1.5} \fill[blue] (0,\z) circle (1pt);
\end{scope}
\begin{scope}[canvas is xz plane at y=0]
\draw[red,dashed] (-1.5,0) -- (0,0) -- (1.5,0);
\foreach \x in {-1.5,1.5} \fill[blue] (\x,0) circle (1pt);
\end{scope}
\end{tikzpicture}
\end{document}
仍有许多地方需要改进,但这可能会让你走上正轨。此外,可能有一个更简单的解决方案pgfplots
。
答案2
其他蒂克兹版本,使用 3D 坐标系:
代码
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\pgfmathsetmacro{\dumbbelllength}{2}
\pgfmathsetmacro{\xangle}{10}
\pgfmathsetmacro{\yangle}{130}
\pgfmathsetmacro{\zangle}{90}
\begin{tikzpicture}
[ x={(\xangle:1cm)},
y={(\yangle:1cm)},
z={(\zangle:1cm)},
scale=2,
]
\foreach \x in {-1,1} \foreach \y in {-1,1} \foreach \z in {-1,1} \coordinate (c\x\y\z) at (\x,\y,\z);
\draw[fill=black,very thick] (0,1,0) -- (0,\dumbbelllength,0) circle (0.05cm);
\draw[fill=black,very thick] (1,0,0) -- (\dumbbelllength,0,0) circle (0.05cm);
\draw[fill=black,very thick] (0,0,-1) -- (0,0,-\dumbbelllength) circle (0.05cm);
\begin{scope}[fill opacity=0.5,draw=black,draw opacity=1,thick]
\filldraw[violet,draw=black] (c-1-1-1) -- (c-11-1) -- (c11-1) -- (c1-1-1) -- cycle;
\filldraw[red,draw=black] (c111) -- (c11-1) -- (c1-1-1) -- (c1-11) -- cycle;
\filldraw[blue,draw=black] (c111) -- (c11-1) -- (c-11-1) -- (c-111) -- cycle;
\draw[very thick] (0,0,-1) -- (0,0,1) (0,-1,0) -- (0,1,0) (-1,0,0) -- (1,0,0);
\filldraw[yellow,draw=black] (c111) -- (c1-11) -- (c-1-11) -- (c-111) -- cycle;
\filldraw[green,draw=black] (c-1-1-1) -- (c-1-11) -- (c-111) -- (c-11-1) -- cycle;
\filldraw[orange,draw=black] (c-1-1-1) -- (c-1-11) -- (c1-11) -- (c1-1-1) -- cycle;
\end{scope}
\draw[fill=black,very thick] (0,-1,0) -- (0,-\dumbbelllength,0) circle (0.05cm);
\draw[fill=black,very thick] (-1,0,0) -- (-\dumbbelllength,0,0) circle (0.05cm);
\draw[fill=black,very thick] (0,0,1) -- (0,0,\dumbbelllength) circle (0.05cm);
\draw[thick] (-2,-2,-2) -- node[below right=1cm] {\huge x} (2,-2,-2);
\draw[thick] (-2,-2,-2) -- node[below left=1cm] {\huge y} (-2,2,-2);
\draw[thick] (-2,2,-2) -- node[left=1cm] {\huge z} (-2,2,2);
\foreach \c in {-2,...,2}
{ \draw (-2,2,\c) node[inner sep=0.05cm,fill=black,circle,label=\zangle+90:\c] {};
\draw (-2,\c,-2) node[inner sep=0.05cm,fill=black,circle,label=\yangle+90:\c] {};
\draw (\c,-2,-2) node[inner sep=0.05cm,fill=black,circle,label=\xangle-90:\c] {};
}
\end{tikzpicture}
\end{document}