我正在尝试将两个边缘标签放置在它们各自的边缘上方和下方。我希望它们相对于边缘居中对齐。这是我当前的代码:
\documentclass[tikz,border=9]{standalone}
\usetikzlibrary{3d}
\usepackage{amsfonts}
\begin{document}
\begin{tikzpicture}[box/.style={rectangle,thick}]
\begin{scope}[x = {(0.5cm,0.5cm)},
y = {(0.95cm,-0.25cm)},
z = {(0cm,0.9cm)},
canvas is yz plane at x=-1]
\draw (-1,-1) rectangle (1,1);
\node[draw,circle,inner sep=1pt,fill=gray](A) at (-.9, -.9) {};
\node[draw,circle,inner sep=1pt,fill=gray](B) at (-.6, -.7) {};
\node[draw,circle,inner sep=1pt,fill=gray](C) at (.7, -.2) {};
\end{scope}
\begin{scope}[x = {(0.5cm,0.5cm)},
y = {(0.95cm,-0.25cm)},
z = {(0cm,0.9cm)},
canvas is xz plane at y=1]
\draw (-1,-1) rectangle (1,1);
\node[draw,circle,inner sep=1pt,fill=gray](D) at (-.5, -.55) {};
\node[draw,circle,inner sep=1pt,fill=gray](E) at (.7, -.1) {};
\node[draw,circle,inner sep=1pt,fill=gray](F) at (-.8, -.08) {};
\end{scope}
\begin{scope}[x = {(0.5cm,0.5cm)},
y = {(0.95cm,-0.25cm)},
z = {(0cm,0.9cm)},
canvas is yx plane at z=1]
\draw (-1,-1) rectangle (1,1);
\node[draw,circle,inner sep=1pt,fill=gray](G) at (.7, .7) {};
\node[draw,circle,inner sep=1pt,fill=gray](H) at (-0.8, .4) {};
\node[above] at (current bounding box.north) {$\mathbb{R}^n$};
\end{scope}
\begin{scope}
\draw[step=0.3,gray,very thin] (2,-2.5) grid ++(3,3);
\node[box,fill=green] at (2.55,-2.25){};
\node[box,fill=green] at (2.25,-2.25){};
\node[box,fill=lime] at (4.05,-1.95){};
\node[box,fill=lime] at (4.65,-1.95){};
\node[box,fill=teal] at (4.65,-1.05){};
\node[box,fill=lime] at (4.35,-1.65){};
\node[box,fill=olive] at (4.65,0.15){};
\node[box,fill=yellow] at (3.75,0.15){};
\draw [<-,red](A.east) to [out=-60,in=-130] (2.55,-2.15);
\draw [->,blue](A.south) to [out=-60,in=-130] (2.55,-2.25) node[sloped,below,font=\tiny] {Label};
\draw [<-,red](B.east) to [out=-60,in=-150] (2.25,-2.15);
\draw [->,blue](B.south) to [out=-60,in=-150] (2.25,-2.25);
\draw [<-,red](C.east) to [out=-60,in=-180] (4.05,-1.90);
\draw [->,blue](C.south) to [out=-60,in=-180] (4.05,-2);
\draw [<-,red](D.east) to [out=0,in=-190] (4.65,-1.90);
\draw [->,blue](D.south) to [out=0,in=-190] (4.65,-2);
\draw [<-,red](E.east) to [out=-30,in=-180] (4.65,-0.99);
\draw [->,blue](E.south) to [out=-30,in=-180] (4.65,-1.09);
\draw [<-,red](F.east) to [out=0,in=-200] (4.35,-1.60);
\draw [->,blue](F.south) to [out=0,in=-200] (4.35,-1.70);
\draw [<-,red](G.east) to [out=10,in=-220] (4.65,0.2) node[sloped,above,font=\tiny] {$P^{-1}$};
\draw [->,blue](G.south) to [out=10,in=-220] (4.65,0.1);
\draw [<-,red](H.east) to [out=-5,in=180] (3.75,0.2);
\draw [->,blue](H.south) to [out=-5,in=180] (3.75,0.1);
\end{scope}
\coordinate(grid) at (2.9,0.5);
\node[above] at (grid.north) {$\mathbb{R}^2$};
\end{tikzpicture}
\end{document}
其结果为:
我尝试使用midway
关键字,但结果却是一个放错位置的标签(至少不是我所期望的):
答案1
像这样吗?
将节点放在边缘末端之前而不是之后
\documentclass[tikz,border=9]{standalone}
\usetikzlibrary{3d}
\usepackage{amsfonts}
\begin{document}
\begin{tikzpicture}[box/.style={rectangle,thick}]
\begin{scope}[x = {(0.5cm,0.5cm)},
y = {(0.95cm,-0.25cm)},
z = {(0cm,0.9cm)},
canvas is yz plane at x=-1]
\draw (-1,-1) rectangle (1,1);
\node[draw,circle,inner sep=1pt,fill=gray](A) at (-.9, -.9) {};
\node[draw,circle,inner sep=1pt,fill=gray](B) at (-.6, -.7) {};
\node[draw,circle,inner sep=1pt,fill=gray](C) at (.7, -.2) {};
\end{scope}
\begin{scope}[x = {(0.5cm,0.5cm)},
y = {(0.95cm,-0.25cm)},
z = {(0cm,0.9cm)},
canvas is xz plane at y=1]
\draw (-1,-1) rectangle (1,1);
\node[draw,circle,inner sep=1pt,fill=gray](D) at (-.5, -.55) {};
\node[draw,circle,inner sep=1pt,fill=gray](E) at (.7, -.1) {};
\node[draw,circle,inner sep=1pt,fill=gray](F) at (-.8, -.08) {};
\end{scope}
\begin{scope}[x = {(0.5cm,0.5cm)},
y = {(0.95cm,-0.25cm)},
z = {(0cm,0.9cm)},
canvas is yx plane at z=1]
\draw (-1,-1) rectangle (1,1);
\node[draw,circle,inner sep=1pt,fill=gray](G) at (.7, .7) {};
\node[draw,circle,inner sep=1pt,fill=gray](H) at (-0.8, .4) {};
\node[above] at (current bounding box.north) {$\mathbb{R}^n$};
\end{scope}
\begin{scope}
\draw[step=0.3,gray,very thin] (2,-2.5) grid ++(3,3);
\node[box,fill=green] at (2.55,-2.25){};
\node[box,fill=green] at (2.25,-2.25){};
\node[box,fill=lime] at (4.05,-1.95){};
\node[box,fill=lime] at (4.65,-1.95){};
\node[box,fill=teal] at (4.65,-1.05){};
\node[box,fill=lime] at (4.35,-1.65){};
\node[box,fill=olive] at (4.65,0.15){};
\node[box,fill=yellow] at (3.75,0.15){};
\draw [<-,red](A.east) to [out=-60,in=-130] (2.55,-2.15);
\draw [->,blue](A.south) to [out=-60,in=-130]node[sloped,below,font=\tiny] {Label} (2.55,-2.25) ; % modified
\draw [<-,red](B.east) to [out=-60,in=-150] (2.25,-2.15);
\draw [->,blue](B.south) to [out=-60,in=-150] (2.25,-2.25);
\draw [<-,red](C.east) to [out=-60,in=-180] (4.05,-1.90);
\draw [->,blue](C.south) to [out=-60,in=-180] (4.05,-2);
\draw [<-,red](D.east) to [out=0,in=-190] (4.65,-1.90);
\draw [->,blue](D.south) to [out=0,in=-190] (4.65,-2);
\draw [<-,red](E.east) to [out=-30,in=-180] (4.65,-0.99);
\draw [->,blue](E.south) to [out=-30,in=-180] (4.65,-1.09);
\draw [<-,red](F.east) to [out=0,in=-200] (4.35,-1.60);
\draw [->,blue](F.south) to [out=0,in=-200] (4.35,-1.70);
\draw [<-,red](G.east) to [out=10,in=-220] (4.65,0.2) node[sloped,above,font=\tiny] {$P^{-1}$};
\draw [->,blue](G.south) to [out=10,in=-220] (4.65,0.1);
\draw [<-,red](H.east) to [out=-5,in=180] (3.75,0.2);
\draw [->,blue](H.south) to [out=-5,in=180] (3.75,0.1);
\end{scope}
\coordinate(grid) at (2.9,0.5);
\node[above] at (grid.north) {$\mathbb{R}^2$};
\end{tikzpicture}
\end{document}