1

I need to draw this on Tex. Could you give me a hand 🤝?

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, fit, positioning, quotes,
                shadows, shapes.geometric, shapes.misc}

\tikzset{FlowChart/.style =
{
  box/.style = {rectangle, draw, fill=white,
               text width=##1, minimum height=8mm, align=center,
               inner sep=2mm, outer sep=0mm,
               drop shadow={shadow xshift=2mm, shadow yshift=-2mm}
               },
box/.default = 22mm,
 cbox/.style = {cross out=1m, draw, very thick,
                inner sep=3mm, node contents={}},
 fbox/.style = {rectangle, draw, densely dashed, inner sep=4mm},
   LA/.style = {semithick, -Triangle}
}
        }

\begin{document}
\pagestyle{empty}
some text
\begin{center}
    \begin{tikzpicture}[FlowChart,
node distance = 0mm and 8mm
                        ]
\node (p1) [box] {Asset Swap Seller};
\node (p2) [box=32mm, above right=of p1] {Bond\\ worth P};
\node (p3) [box, below right=of p2] {Asset Swap Buyer};
%
\draw [LA]  (p1 |- p2) -- (p2)
            (p2) -- (p2 -| p3);
%
\coordinate[below=4mm of p1.south] (c);
\draw [LA]  (p3.south |- c) to ["100"]  (c);
% fake node,
\node[right=38mm of p3.east] {};
    \end{tikzpicture}
\end{center}
some text
\begin{center}
    \begin{tikzpicture}[FlowChart,
node distance = 0mm and 8mm
                        ]
\node (p1) [box] {Asset Swap Seller};
\node (p2) [box, right=48mm of p1] {Asset Swap Buyer};
\node (p3) [box, right=16mm of p2] {Bond};
%
\node (p4) [fbox, fit=(p1) (p2)]  {};
%
\coordinate[above=2mm of p1.east] (c1);
\coordinate[below=2mm of p1.east] (c2);
\draw [LA]  (c1 -| p2.west) to ["C" '] (c1);
\draw [LA]  (c2) to ["LIBOR + C" '] (c2 -| p2.west);
%
\draw [LA,very thick]  (p3) to ["C" ']  (p2);
    \end{tikzpicture}
\end{center}
some text
\begin{center}
    \begin{tikzpicture}[FlowChart,
node distance = 0mm and 8mm
                        ]
\node (p1) [box] {Asset Swap Seller};
\node (p2) [box, right=48mm of p1] {Asset Swap Buyer};
\node (p3) [box, right=16mm of p2] {Bond};
%
\node (p4) [fbox, fit=(p1) (p2)]  {};
\node      [cbox, fit=(p3)];
%
\coordinate[above=2mm of p1.east] (c1);
\coordinate[below=2mm of p1.east] (c2);
\draw [LA]  (c1 -| p2.west) to ["C" '] (c1);
\draw [LA]  (c2) to ["LIBOR + C" '] (c2 -| p2.west);
%
\draw [LA,very thick]  (p3) to ["C" ']  (p2);
    \end{tikzpicture}
\end{center}
some text
\end{document}
6
  • How is the code in your question (that is by the way quite similar/identical to the one in this answer) related to the screenshot of the desired output you showed?
    – leandriis
    Sep 9 '19 at 11:28
  • Yes. I got it from there just to put a mwe.
    – Delan
    Sep 9 '19 at 11:31
  • But as far as I can see, the example code is not at all related to teh image you would like to have or do I overlook something? Did you try to make any adjustments?
    – leandriis
    Sep 9 '19 at 11:32
  • I got stuck at the outer boxes and then I dropped the mic.
    – Delan
    Sep 9 '19 at 11:33
  • 1
    Probably helpful regarding the boxes around parts of the flowchart: tex.stackexchange.com/q/204783/134144 and regarding the curly brace: tex.stackexchange.com/q/20885/134144
    – leandriis
    Sep 9 '19 at 11:47
3

None of this is difficult, and leaandris has already provided you with useful links. You would learn much more if you tried them out yourself. (I did not have the patience to type in all the texts.)

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning,decorations.pathreplacing,shapes.arrows}
\begin{document}
\begin{tikzpicture}[font=\sffamily\bfseries,
standard/.style={draw=blue!70,minimum height=2em,minimum
width=#1,text=blue},
partitioned/.style={standard=#1,path picture={
\path(path picture bounding box.south west)
-- (path picture bounding box.south east) foreach \XX [count=\YY] 
in {0.1,0.2,...,0.6,0.9} {coordinate[pos=\XX] (aux\YY)};
\draw foreach \YY in {1,...,7} {(aux\YY) -- 
(aux\YY|-path picture bounding box.north)};
\draw[dotted,thick,shorten >=1ex,shorten <=1ex] (path picture bounding box.west-|aux6) 
-- (path picture bounding box.west-|aux7);}},
marrow/.style={sloped,minimum height=1.4cm,minimum width=1.2cm,
   single arrow, single arrow head extend=.125cm, allow upside down,
   top color=blue!30,bottom color=blue!70,scale=0.4}]
   \node[standard=8em] (T1) {Training Set}; 
   \node[standard=5em,right=0pt of T1] (T2) {Test Set}; 
   \node[above left=1.5ex of T1.north west,above right] (L1) 
   {\underline{Step 1: blablablablablablablablabla}};
   \begin{scope}[local bounding box=pft]
    \node[below=6em of T1,partitioned=8em] (T3){};
    \node[right=1ex of T3,blue] (T4) {Training Set};
    \node[above=1.5ex of T3.north west,above right] (L2a) 
     {\underline{(i) blablablablablablablablabla}};
    \node[below=4em of T3.south west,above right] (L2b) 
     {\underline{(ii) blablablablablablablablabla}};
    \draw[very thick,decorate,decoration={brace,mirror,raise=0.5ex}] (T3.south west) -- (T3.south east)
    node[midway,below=1ex] {$k$ parts};
    \draw[very thick,decorate,decoration={brace,mirror,raise=0.5ex}] 
    (L2a.north west) -- (L2b.south west)
    node[midway,left=1ex,align=left] {\underline{Step 2:}\\
    \underline{$k$ fold cross}\\ \underline{validation}};
    \path (T3.-20) coordinate(aux)  -- (L2b.north-|aux) node[pos=0.6,marrow]{};
    \node[standard=8em,below=8em of aux] (T5) {Training Set};
    \node[above=1ex of T5] (L3) 
    {\underline{Step 3: blablablablablablablablabla}};
    \node[right=1em of T5,text width=4.5cm,font=\small\sffamily] {Note: use the configuration of the
    tuning parameters with the lowest cv.error};
    \path (L2b.south-|aux) -- (L3.north) node[midway,marrow]{};
    \node[standard=8em,below=4em of T5] (T6) {Test Set};
    \node[above=1ex of T6] (L4) 
    {\underline{Step 4: blablablablablablablablabla}};
    \path (T5.south) -- (L4.north) node[midway,marrow]{};
   \end{scope}
   \draw[red] ([xshift=-1ex,yshift=-1ex]pft.south west) rectangle 
   ([xshift=1ex,yshift=1ex]pft.north east);
   \node[above=0.3ex of pft] (Use){Use the following blablablablablablablablabla};
   \path (pft.north|-T1.south) -- (pft.north|-Use.north) node[midway,marrow]{};
\end{tikzpicture}
\end{document}

enter image description here

6
  • Cat! Thank you very much. It might be easy for you but, for me, it takes a lot of time (trial & error) and I end up getting the wrong answer. Although each time I try I get closer to a better result, meaning, better at tikZ.
    – Delan
    Sep 9 '19 at 20:18
  • Could you add the note part that says “Note: use the configuration of the tuning parameters with the lowest cv.error”
    – Delan
    Sep 10 '19 at 0:35
  • 1
    @Delan I added it. It is \node[right=1em of T5,text width=4.5cm,font=\small\sffamily] {Note: use the configuration of the tuning parameters with the lowest cv.error};. (The code was written in such a way that the box grows accordingly, this is the purpose of local bounding box.
    – user194703
    Sep 10 '19 at 0:41
  • Fantastic! Thank you very much!
    – Delan
    Sep 10 '19 at 0:42
  • 1
    @Delan Replace the very last \path command by \path (T1.south) -- (T1.south|-Use.north) node[midway,marrow]{};.
    – user194703
    Sep 10 '19 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.