[英]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}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.