# pgfplotstable, table overlapping graphic

I have a pgfplots graphic in a pgfplotstable, and a part of the graphic is overlapped by the table like you can see in this picture:

The 800 at the top is cut by the tabular border.

Here is a MWE:

\documentclass[border=10pt]{standalone}
\usepackage{filecontents}
\begin{filecontents}{data.txt}
n   T1  T2  MCp Q1  Q2  T
1   295 145 8   0   1200    95
2   145 45  2   100 100 95
3   195 45  3   150 300 95
4   195 295 5   0   500 95
5   95  195 8   0   800 95
6   45  195 4   200 400 95
\end{filecontents}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
\newcommand\powernode[4]{%\powernode{T°}{nL1}{NL2}{Q}
\node[draw, circle] at (axis cs:#1,#2) { };
\node[draw, circle] at (axis cs:#1,#3) { };
\node at (axis cs:#1,#2-0.5) {\tiny #4};
}

\pgfplotsset{every axis plot post/.append style={mark=arrow}}

% Get number of rows in datafile
\pgfplotstablegetrowsof{\data}
\let\numberofrows=\pgfplotsretval

% Print the table
\pgfplotstabletypeset[columns={n,T,MCp,Q1,Q2},
% Booktabs rules
every head row/.style = {before row=\toprule, after row=\midrule},
every last row/.style = {after row=[3ex]\bottomrule},
columns/n/.style = {string type, column name=Flux},
% Call the command in a multirow cell in the first row, keep empty for all other rows
columns/T/.style = {
column name = {},
assign cell content/.code = {% use \multirow for Z column:
\ifnum\pgfplotstablerow=0
\pgfkeyssetvalue{/pgfplots/table/@cell content}
{\multirow{\numberofrows}{7cm}{
\begin{tikzpicture}[trim axis left,trim axis right]
\begin{axis}[y=-\baselineskip,
scale only axis,
width             = 6.5cm,
enlarge y limits  = {abs=0.5},
axis y line*      = middle,
y axis line style = dashed,
ytick             = \empty,
axis x line*      = bottom]
\powernode{125}{2}{6}{100}
\powernode{175}{3}{6}{300}
\powernode{160}{1}{5}{800}
\end{axis}
\end{tikzpicture}
}}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
}
},
% Format numbers and titles
columns/MCp/.style = {column name = MCP, fixed, dec sep align, use comma, set thousands separator={\ }},
columns/Q1/.style  = {column name = $Q_1$, fixed, dec sep align, use comma, set thousands separator={\ }},
columns/Q2/.style  = {column name = $Q_2$, fixed, dec sep align, use comma, set thousands separator={\ }}
]{\data}
\end{document}


Is it possible to make the tabular border background transparent so the 800 would be displayed correctly?

I know my MWE is not really minimal. I posted that much because I'll be sure the problem is solved if solved on this example, and that I know that my way to manage my code is not the optimal way, so that allow for suggestion on this side too. And even if this is not optimal, it may inspire other that would be interested on similar result. I'm aware that the physics behind the problem is not respected, it's an example for the drawing point of view

• Running the tikzpicture by itself causes the 800 to get clipped. Expand y limits = {abs=.7} will fix that. – John Kormylo Nov 20 '14 at 22:16
• @JohnKormylo venlarge y limits = {abs=0.7}, does in deed fully display the 800, but it modify the size of the graphic in a way that the red and blues lines are no more perfectly aligned with the tabular. – Togh Nov 21 '14 at 8:38

Running the tikzpicture by itself causes the 800 to get clipped. Expanding the y limits via enlarge y limits = {abs=0.7}, will fix that.

Additionally you can use \raisebox to adjust the alignment. Note, the first argument of \raisebox moves the baseline, which has no effect. The second argument changes the (apparent) height. The 3.05cm was obtained by trial and error.

\documentclass[border=10pt]{standalone}
\usepackage{filecontents}
\begin{filecontents}{data.txt}
n   T1  T2  MCp Q1  Q2  T
1   295 145 8   0   1200    95
2   145 45  2   100 100 95
3   195 45  3   150 300 95
4   195 295 5   0   500 95
5   95  195 8   0   800 95
6   45  195 4   200 400 95
\end{filecontents}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
\newcommand\powernode[4]{%\powernode{T°}{nL1}{NL2}{Q}
\node[draw, circle] at (axis cs:#1,#2) { };
\node[draw, circle] at (axis cs:#1,#3) { };
\node at (axis cs:#1,#2-0.5) {\tiny #4};
}

\pgfplotsset{every axis plot post/.append style={mark=arrow}}

% Get number of rows in datafile
\pgfplotstablegetrowsof{\data}
\let\numberofrows=\pgfplotsretval

% Print the table
\pgfplotstabletypeset[columns={n,T,MCp,Q1,Q2},
% Booktabs rules
every head row/.style = {before row=\toprule, after row=\midrule},
every last row/.style = {after row=[3ex]\bottomrule},
columns/n/.style = {string type, column name=Flux},
% Call the command in a multirow cell in the first row, keep empty for all other rows
columns/T/.style = {
column name = {},
assign cell content/.code = {% use \multirow for Z column:
\ifnum\pgfplotstablerow=0
\pgfkeyssetvalue{/pgfplots/table/@cell content}
{\multirow{\numberofrows}{7cm}{\raisebox{0pt}[3.05cm]{%
\begin{tikzpicture}[trim axis left,trim axis right]
\begin{axis}[y=-\baselineskip,
scale only axis,
width             = 6.5cm,
enlarge y limits  = {abs=0.7},
axis y line*      = middle,
y axis line style = dashed,
ytick             = \empty,
axis x line*      = bottom]
\powernode{125}{2}{6}{100}
\powernode{175}{3}{6}{300}
\powernode{160}{1}{5}{800}
\end{axis}
\end{tikzpicture}
}}}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
}
},
% Format numbers and titles
columns/MCp/.style = {column name = MCP, fixed, dec sep align, use comma, set thousands separator={\ }},
columns/Q1/.style  = {column name = $Q_1$, fixed, dec sep align, use comma, set thousands separator={\ }},
columns/Q2/.style  = {column name = $Q_2$, fixed, dec sep align, use comma, set thousands separator={\ }}
]{\data}
\end{document}