我已经画了一个 3x3x3 的立方体(Stefan Kottwitz 绘制),如何去除魔方的一个角?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[on grid]
\shade[yslant=-0.5,right color=gray!10, left color=black!50]
(0,0) rectangle +(3,3);
\draw[yslant=-0.5] (0,0) grid (3,3);
\shade[yslant=0.5,right color=gray!70,left color=gray!10]
(3,-3) rectangle +(3,3);
\draw[yslant=0.5] (3,-3) grid (6,0);
\shade[yslant=0.5,xslant=-1,bottom color=gray!10,
top color=black!80] (6,3) rectangle +(-3,-3);
\draw[yslant=0.5,xslant=-1] (3,0) grid (6,3);
\end{tikzpicture}
\end{document}
答案1
像这样?
我只是使用了 Stefan 定义的网格之一,并绘制了一个白色填充的矩形(我将其向外边框做得稍大一些,以便网格线也被吞没)。我承认我选择了最简单的角落。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[on grid]
\shade[yslant=-0.5,right color=gray!10, left color=black!50]
(0,0) rectangle +(3,3);
\draw[yslant=-0.5] (0,0) grid (3,3);
\shade[yslant=0.5,right color=gray!70,left color=gray!10]
(3,-3) rectangle +(3,3);
\draw[yslant=0.5] (3,-3) grid (6,0);
\shade[yslant=0.5,xslant=-1,bottom color=gray!10,
top color=black!80] (6,3) rectangle +(-3,-3);
\draw[yslant=0.5,xslant=-1] (3,0) grid (6,3);
\fill[yslant=0.5,xslant=-1,white] (5,2) rectangle ++(1.1,1.1);
\end{tikzpicture}
\end{document}
附录:为了好玩:使用 pgfplots,使用这个答案。为了删除一个或多个立方体,您只需从数据文件中删除相应的行。在示例中,我删除了最后一行,该行对应于前上角。
\documentclass[tikz,border=3.14pt]{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.15}
\usepackage{filecontents}
\begin{filecontents*}{cubes.dat}
x,y,z,data
0,0,0,1.0
0,0,1,1.6
0,0,2,13.0
0,1,0,1.7
0,1,1,11.0
0,1,2,18.6
0,2,0,4.9
0,2,1,4.3
0,2,2,1.2
1,0,0,1.0
1,0,1,1.6
1,0,2,13.0
1,1,0,1.7
1,1,1,11.0
1,1,2,18.6
1,2,0,4.9
1,2,1,4.3
1,2,2,1.2
2,0,0,1.0
2,0,1,1.6
2,0,2,13.0
2,1,0,1.7
2,1,1,11.0
2,1,2,18.6
2,2,0,4.9
2,2,1,4.3
\end{filecontents*} % I removed the last line 2,2,2,1.2
% And yes, I know that the data column is irrelevant here
\pgfplotsset{
colormap={softgray}{gray(0cm)=(0.5); gray(1cm)=(0.6)}
}
\begin{document}
%
\begin{tikzpicture}
\begin{axis}[% from section 4.6.4 of the pgfplotsmanual
view={120}{40},
width=110pt,
height=170pt,
grid=major,
axis lines=none,
z buffer=sort,
%point meta=explicit,
colormap name={softgray},
scatter/use mapped color={
draw=mapped color,fill=mapped color!70},
]
\addplot3 [only marks,scatter,mark=cube*,mark size=24,opacity=1]
table[col sep=comma,header=true,x expr={\thisrow{x}},
y expr={\thisrow{y}},z expr={\thisrow{z}} ] {cubes.dat};
\end{axis}
\end{tikzpicture}
\end{document}
不透明度为0.8。