我想创建一个包含 4 个框的坐标系!但我无法做到:
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{arrows.meta, matrix}
\usepackage{lmodern}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\matrix (lang) [matrix of nodes, column sep=3mm, row sep=3mm,
nodes={anchor=center, minimum width=3cm, minimum height=2cm, rounded corners=0mm,
fill=cyan!90!black, draw=cyan!50!black, line width=.5mm}]
{ 1 & 2 \\
3 & 4 \\};
\draw [->, shorten >=-3mm](lang.south west)--(lang.south east);
\node[below] at (lang.south-|lang-1-1.center) {};
\node[below] at (lang.south-|lang-1-2.center) {};
\draw [->, shorten >=-3mm](lang.south west)--(lang.north west);
\node[rotate=90, above] at (lang.west|-lang-2-1.center) {};
\node[rotate=90, above] at (lang.west|-lang-1-1.center) {};
\draw[dashed] (lang.south) node[below=5mm, font=\bfseries\sffamily]{}--(lang.north);
\draw[dashed] (lang.west) node[rotate=90, above=5mm, font=\bfseries\sffamily]{} --(lang.east);
%\node
\end{tikzpicture}
\end{document}
以下是一个例子
答案1
您可以使用rectange split
形状第二部分几乎是空的。
由于形状将忽略任何minimum height
要求,我只需添加一个高度为 1.5 厘米的隐形规则。第二个节点部分的高度将是 1.5 厘米 + 2 × 内部 ysep。
代码
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{arrows.meta, matrix}
\usetikzlibrary{shapes.multipart}
\begin{document}
\begin{tikzpicture}
\matrix (lang) [
matrix of nodes, column sep=3mm, row sep=3mm,
every two node part/.style={execute at begin node=\rule{0pt}{1.5cm}},
nodes={
minimum width=3cm, fill=cyan!90!black, draw=cyan!50!black, line width=.5mm,
rectangle split, rectangle split parts=2}]{
1 \nodepart{two} & 2 \nodepart{two} \\
3 \nodepart{two} & 4 \nodepart{two} \\
};
\draw [<->, shorten <=-3mm, shorten >=-3mm]
(lang.north west) node[above=3mm]{$y$}
|- (lang.south east) node[right=3mm]{$x$};
\draw[dashed] (lang.south) --(lang.north)
(lang.west) -- (lang.east);
\end{tikzpicture}
\end{document}