2

I currently have the following table:enter image description here

Which corresponds to the following code:

\begin{table}[h] 
\scriptsize
 % \centering
  \caption{Permutation Importance}
\resizebox{\textwidth}{!}{\begin{tabular}{lcccccccc} \toprule
 &  \ldots   & $\text{M2}^{(\text{SMB})}$ & $\text{M2}^{(\text{HML})}$ & $\text{DJI}^{(\text{MOM})}$ & $\text{DJI}^{(\text{SMB})}$ & $\text{DJI}^{(\text{HML})}$ & $\text{CAPE}^{(\text{MOM})}$ & \ldots  \\ \midrule
1 & \ldots   & 0.20 & 1.93 & 0.10 & 0.32 & 1.39 & -2.50 & \ldots \\ 
2  & \ldots   & -0.02 & 3.17 & -0.006 & -0.44 & 5.41 & -4.34  & \ldots \\ 
3  & \ldots   & 0.54 & 5.53 & 0.10 & -2.71 & 21.82 & -6.61 & \ldots  \\ 
4  & \ldots   & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79  & \ldots \\ 
\ldots  & \ldots   & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots  & \ldots \\ 
\ldots  & \ldots   & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots  & \ldots \\ 
$N_{t} - 2$  & \ldots   & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79  & \ldots \\ 
$N_{t} - 1$  & \ldots   & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79  & \ldots \\ 
$N_{t}$  & \ldots   & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79  & \ldots \\ 

\bottomrule
\end{tabular}} \label{tab:fac_char}
\end{table}

Now my intention is to draw arrows for the DJI^(MOM), DJI^(SMB), and DJI^(HML), to indicate that they are being randomly reshuffled simultaneously. I came across the following picture online, which illustrates what I mean for 1 column: enter image description here

I figured I would have to use the Tikz package, but I have no clue where to even begin..

John
  • 643

1 Answers1

5

This is a starting point.

\documentclass{article} 
\usepackage{amsmath} 
\usepackage{tikz} 
\usetikzlibrary{matrix,decorations.pathreplacing,calc} 
\begin{document} 
\begin{tikzpicture}[fancy arrow/.style={decorate,decoration={ 
show path construction, 
curveto code={ 
\draw[top color=red,bottom color=yellow] 
let \p1=($(\tikzinputsegmentsupporta)-(\tikzinputsegmentfirst)$) in 
[/utils/exec=\pgfmathsetmacro{\mysign}{sign(\x1)}] 
([yshift=-1.5pt]\tikzinputsegmentfirst) .. controls 
([yshift=-1.5pt]\tikzinputsegmentsupporta) and ([yshift=-1.5pt]\tikzinputsegmentsupportb) 
..([yshift=-1.5pt,xshift=\mysign*3pt]\tikzinputsegmentlast) 
-- ([yshift=-1.5pt,xshift=\mysign*1.5pt]\tikzinputsegmentlast) 
-- ([yshift=-3pt,xshift=\mysign*1.5pt]\tikzinputsegmentlast) 
-- (\tikzinputsegmentlast) 
-- ([yshift=3pt,xshift=\mysign*1.5pt]\tikzinputsegmentlast) 
-- ([yshift=1.5pt,xshift=\mysign*1.5pt]\tikzinputsegmentlast) 
.. controls 
([yshift=1mm]\tikzinputsegmentsupportb) and ([yshift=1mm]\tikzinputsegmentsupporta) 
.. ([yshift=1mm]\tikzinputsegmentfirst) -- cycle;}}}] 
\matrix[matrix of math nodes,cells={nodes={scale=0.8}}, 
column 1/.style={nodes={text width=4em,align=left}}] (mat) { 
& \ldots & \text{M2}^{(\text{SMB})} & \text{M2}^{(\text{HML})} & \text{DJI}^{(\text{MOM})} & \text{DJI}^{(\text{SMB})} & \text{DJI}^{(\text{HML})} & \text{CAPE}^{(\text{MOM})} & \ldots \\ 
1 & \ldots & 0.20 & 1.93 & 0.10 & 0.32 & 1.39 & -2.50 & \ldots \\ 
2 & \ldots & -0.02 & 3.17 & -0.006 & -0.44 & 5.41 & -4.34 & \ldots \\ 
3 & \ldots & 0.54 & 5.53 & 0.10 & -2.71 & 21.82 & -6.61 & \ldots \\ 
4 & \ldots & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79 & \ldots \\ 
\ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots \\ 
\ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots & \ldots \\ 
N_{t} - 2 & \ldots & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79 & \ldots \\ 
N_{t} - 1 & \ldots & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79 & \ldots \\ 
N_{t} & \ldots & 0.24 & 1.64 & 0.15 & -1.77 & 21.74 & -1.79 & \ldots \\ 
}; 
\draw[fancy arrow] (mat-2-5.east) to[out=0,in=0,looseness=1.5](mat-3-5.east); 
\draw[fancy arrow] (mat-4-5.west) to[out=180,in=180,looseness=1.5](mat-3-5.west); 
\path (mat-1-2.south) -- (mat-2-2.north) coordinate[pos=0.2] (aux); 
\draw[very thick] (mat.north west) -- (mat.north east) 
(aux-|mat.west) -- (aux-|mat.east) (mat.south west) -- (mat.south east); 
\end{tikzpicture} 
\end{document}

enter image description here

CarLaTeX
  • 62,716
  • Thanks for your answer, this really helps! I have one more question regarding the arrows for the LHS of a column. I tried doing it like this: \draw[arrow] (mat-2-5.west) toout=0,in=0,looseness=1.5;. But in this case, the arrow was still pointing in the wrong direction. – John Jul 15 '19 at 08:56
  • @Keith Use to[out=180,in=180] instead. These numbers refer to degrees counterclockwise where 0 is at the nodes right (east) side. – sodd Jul 15 '19 at 09:49
  • Thank you sodd, this works! The only problem is that the arrow tip is still facing to the left and not to the right. Do you know how I can fix this? – John Jul 15 '19 at 09:55
  • @Keith See marmot's renewed answer. – CarLaTeX Jul 16 '19 at 20:11