我想在 TikZ 中画一些类似的东西:
我尝试过 LatexDraw,但是这个程序在 PStricks 中生成非常混乱的代码:
\begin{pspicture}(0,-0.8)(13.2,0.8)
\definecolor{colour0}{rgb}{0.99607843,0.99607843,0.99607843}
\psframe[linecolor=black, linewidth=0.02, fillstyle=solid,fillcolor=colour0, dimen=outer](10.4,0.8)(8.8,-0.8)
\psframe[linecolor=black, linewidth=0.02, fillstyle=solid,fillcolor=colour0, dimen=outer](1.6,0.8)(0.0,-0.8)
\psline[linecolor=black, linewidth=0.02, arrowsize=0.05291667cm 2.0,arrowlength=1.4,arrowinset=0.0]{->}(1.6,0.0)(2.4,0.0)(2.4,0.0)
\psframe[linecolor=black, linewidth=0.02, fillstyle=solid,fillcolor=colour0, dimen=outer, framearc=0.54122657](4.8,0.8)(2.8,-0.8)
\psellipse[linecolor=black, linewidth=0.02, fillstyle=solid, dimen=outer](6.8,0.0)(0.8,0.8)
\psellipse[linecolor=black, linewidth=0.02, fillstyle=solid, dimen=outer](12.4,0.0)(0.8,0.8)
\rput(0.8,0.0){\tiny{Dane uczące}}
\rput(3.8,0.0){\tiny{Trenowanie
\\
algorytmu}}
\rput(6.8,0.0){\tiny{Model}}
\rput(9.6,0.0){\tiny{Dane testowe}}
\rput(12.4,0.0){\tiny{Dokładność}}
\psline[linecolor=black, linewidth=0.02, arrowsize=0.05291667cm 2.0,arrowlength=1.4,arrowinset=0.0]{->}(4.8,0.0)(5.6,0.0)(5.6,0.0)
\psline[linecolor=black, linewidth=0.02, arrowsize=0.05291667cm 2.0,arrowlength=1.4,arrowinset=0.0]{->}(7.6,0.0)(8.4,0.0)(8.4,0.0)
\psline[linecolor=black, linewidth=0.02, arrowsize=0.05291667cm 2.0,arrowlength=1.4,arrowinset=0.0]{->}(10.4,0.0)(11.2,0.0)(11.2,0.0)
\end{pspicture}
并且在我的文档中无法正确呈现:
答案1
使用 TikZ:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
chains,
positioning,
shapes.geometric
}
% for fancy looks of data storages
\begin{document}
\begin{tikzpicture}[
node distance = 5mm and 7mm,
start chain = going right,
disc/.style = {shape=cylinder, draw, shape aspect=0.3,
shape border rotate=90,
text width=17mm, align=center, font=\linespread{0.8}\selectfont},
mdl/.style = {shape=ellipse, aspect=2.2, draw},
alg/.style = {draw, align=center, font=\linespread{0.8}\selectfont}
]
\begin{scope}[every node/.append style={on chain, join=by -Stealth}]
\node (n1) [disc] {Training\\ data};
\node (n2) [alg] {Learning\\ algorithm};
\node (n3) [mdl] {Model};
\node (n4) [disc] {Test\\ data};
\node (n3) [mdl] {Accuracy};
\end{scope}
\node[below=of n2] {Step 1: Training};
\node[below=of n4] {Step 2: Tresting};
\end{tikzpicture}
\end{document}
答案2
使用 PSTricks
\documentclass{article}
\usepackage{pst-node}
\def\data#1{%
\pspicture(-0.45,-0.5)(0.45,0.5)
\psline(-0.45,0.5)(-0.45,-0.5)\psellipticarc(0,-0.5)(0.45,0.1){180}{0}\psline(0.45,-0.5)(0.45,0.5)
\psellipse(0,0.5)(0.45,0.1)\rput(0,0){#1}
\endpspicture}
\begin{document}
\begin{pspicture}(0,-2)(11,2)
\rput(1,0){\rnode{A}{\data{\tiny\shortstack{Training\\data}}}}
\rput(3,0){\rnode{B}{\psframebox{\tiny\shortstack{Learning\\algorithm}}}}
\rput(5,0){\rnode{C}{\psovalbox{\tiny Model}}}
\rput(7,0){\rnode{D}{\data{\tiny\shortstack{Test\\data}}}}
\rput(9,0){\rnode{E}{\psovalbox{\tiny Model}}}
\ncline{->}{A}{B}\ncline{->}{B}{C}\ncline{->}{C}{D}\ncline{->}{D}{E}\ncline{->}{E}{F}
\uput{1cm}[-90](B){Step1: Training}\uput{1cm}[-90](D){Step 2: Testing}
\end{pspicture}
\end{document}
答案3
另一个解决方案是pstricks
。它需要在最后添加一些纠正代码,因为出于某种原因,圆柱体中出现了不规则的箭头。
\documentclass[x11names, dvipsnames, svgnames, border=3pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pstricks-add, pst-3dplot, pst-text, auto-pst-pdf}%
\begin{document}
\psset{dimen=outer, arrowinset=0.12, arrows=->}
\sffamily
\begin{psmatrix}[rowsep=3.5, colsep=1]%=2.5
\Rnode{DU}{\pstIIIDCylinder[fillstyle=solid, linecolor=Gainsboro! 80!LightGray, fillcolor=Gainsboro!75, increment =0.4](0,0,-1){1}{2.5} \pstextpath[c]{\psellipticarc[linestyle=none](0, 0.2)(1,.4){180}{0}}{\color{blue}\begin{tabular}{c}Dane\\uczące\end{tabular}}}
&\hspace{3em} \Rnode{TA}{\psframebox[linecolor=DarkSeaGreen3, dimen=outer, framearc=0.54122657, framesep=10pt]{\begin{tabular}{@{}c@{}}Trenowanie\\
algorytmu\end{tabular}}}
& \ovalnode[linecolor=yellow]{My}{\raisebox{0pt}[0.4cm][0.3cm]{\quad Model\quad}}
&\hspace{3em}\Rnode{DT}{\pstIIIDCylinder[fillstyle=solid, linecolor=Gainsboro! 80!LightGray, fillcolor=Gainsboro!75, increment =0.4](0,0,-1){1}{2.5} \pstextpath[c]{\psellipticarc[linestyle=none](0, 0.2)(1,.4){180}{0}}{\color{blue}\begin{tabular}{c}Dane\\testowe\end{tabular}}} \hspace{3em}
& \ovalnode{M}{\raisebox{0pt}[0.4cm][0.3cm]{Dokładność}}
%% Connections
\ncline[nodesepA=1]{DU}{TA}
\ncline{TA}{My}
\ncline[nodesepB=1]{My}{DT}
\ncline[nodesepA=1]{DT}{M}%
%%Corrections
\pnodes[1,0](DU){CDU}(DT){CDT}
\rput(CDU){\psframe*[linecolor =Gainsboro](-4pt,-3pt)(0.4pt, 3pt)}
\rput(CDT){\psframe*[linecolor =Gainsboro](-4pt,-3pt)(0.4pt, 3pt)}
\end{psmatrix}
\end{document}