创建数据分区图
Create data partition figure
我想在 Latex 中创建一个与此类似的图形(但在块中也有百分比):
我成功做到了这一点 (MWE):
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}
\usepackage{xcolor}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\tikzset{
train/.style={
text=black,
draw,
minimum height=1cm,
minimum width=7cm,
left color=orange, right color=orange!30!white,shading angle=90},
val/.style={
draw,
text=black,
minimum height=1cm,
minimum width=2cm,
left color=orange!30!white, right color=green!30!white,shading angle=90},
test/.style={
draw,
text=black,
fill=cyan,
minimum height=1cm,
minimum width=1cm}}
\begin{tikzpicture}[thin,black]
\path
(0,0) node[train] (N) {70\%}
++(0:4.5) node[val] (C) {20\%}
+(0:2) node[test] (O) {10\%};
\end{tikzpicture}
\end{document}
结果是:
显然,带有训练、验证和测试描述的箭头仍然缺失,我无法找到如何创建它。
我该怎么做?
谢谢!
一般我会推荐decorations.pathreplacing
库给tikz图片加大花括号,但在这个特殊的淤积中,画几条圆角的路径可能会更容易:
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}
\usepackage{xcolor}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\tikzset{
train/.style={
text=black,
draw,
minimum height=1cm,
minimum width=7cm,
left color=orange, right color=orange!30!white,shading angle=90},
val/.style={
draw,
text=black,
minimum height=1cm,
minimum width=2cm,
left color=orange!30!white, right color=green!30!white,shading angle=90},
test/.style={
draw,
text=black,
fill=cyan,
minimum height=1cm,
minimum width=1cm}}
\begin{tikzpicture}[thin,black]
\path
(0,0) node[train] (N) {70\%}
++(0:4.5) node[val] (C) {20\%}
+(0:2) node[test] (O) {10\%};
\draw[->,rounded corners=1mm] (-3.5,0.6) |- (0,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (3.5,0.6) |- (0,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (3.5,0.6) |- (4.5,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (5.5,0.6) |- (4.5,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (6,0.6) |- (6.5,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (7,0.6) |- (6.5,1) -- ++(0,0.5);
\node at (0,1.7) {Train};
\node at (4.5,1.7) {Validation};
\node at (6.5,1.7) {Test};
\end{tikzpicture}
\end{document}
我想在 Latex 中创建一个与此类似的图形(但在块中也有百分比):
我成功做到了这一点 (MWE):
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}
\usepackage{xcolor}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\tikzset{
train/.style={
text=black,
draw,
minimum height=1cm,
minimum width=7cm,
left color=orange, right color=orange!30!white,shading angle=90},
val/.style={
draw,
text=black,
minimum height=1cm,
minimum width=2cm,
left color=orange!30!white, right color=green!30!white,shading angle=90},
test/.style={
draw,
text=black,
fill=cyan,
minimum height=1cm,
minimum width=1cm}}
\begin{tikzpicture}[thin,black]
\path
(0,0) node[train] (N) {70\%}
++(0:4.5) node[val] (C) {20\%}
+(0:2) node[test] (O) {10\%};
\end{tikzpicture}
\end{document}
结果是:
显然,带有训练、验证和测试描述的箭头仍然缺失,我无法找到如何创建它。
我该怎么做?
谢谢!
一般我会推荐decorations.pathreplacing
库给tikz图片加大花括号,但在这个特殊的淤积中,画几条圆角的路径可能会更容易:
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}
\usepackage{xcolor}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\tikzset{
train/.style={
text=black,
draw,
minimum height=1cm,
minimum width=7cm,
left color=orange, right color=orange!30!white,shading angle=90},
val/.style={
draw,
text=black,
minimum height=1cm,
minimum width=2cm,
left color=orange!30!white, right color=green!30!white,shading angle=90},
test/.style={
draw,
text=black,
fill=cyan,
minimum height=1cm,
minimum width=1cm}}
\begin{tikzpicture}[thin,black]
\path
(0,0) node[train] (N) {70\%}
++(0:4.5) node[val] (C) {20\%}
+(0:2) node[test] (O) {10\%};
\draw[->,rounded corners=1mm] (-3.5,0.6) |- (0,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (3.5,0.6) |- (0,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (3.5,0.6) |- (4.5,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (5.5,0.6) |- (4.5,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (6,0.6) |- (6.5,1) -- ++(0,0.5);
\draw[->,rounded corners=1mm] (7,0.6) |- (6.5,1) -- ++(0,0.5);
\node at (0,1.7) {Train};
\node at (4.5,1.7) {Validation};
\node at (6.5,1.7) {Test};
\end{tikzpicture}
\end{document}