Please let me explain the motivation behind this a bit more broadly. I'd like to draw measured benchmark values as follows: background/nothing between the x-axis and the minimum value a green area between the minimum value and the median a black line at the median a red area between the median and the maximum value background/nothing above the maximum
I tried various attempts to reach this before using the IMHO quite inelegant way of just drawing a white area on top of the other plots (although after all the pain I think I can live with that :), the code below shows that and how an alternative solution should look like too.
One try was to use stacked plots, but of course the values are stacked and I could not find an equivalent to bar shift=0pt
. I also think there is no way to disable the stacking per plot (or the other way around, i.e. disable it globally but enable it for selected plots).
The most similar solution I could find yet is Fill between two curves in pgfplots. but I could not get it to work with the pre-existing table data I have (is there really no easy way to copy selected columns into a new table!?). Is the white area approach below really the best way to do this?
\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstableread{
size min max med
1 1 3 2
10 2 4 3
}{\loadedtable}
\begin{tikzpicture}
\begin{axis}[
legend entries={above median,below median, median,},
ymin=0,
area style,
]
\addplot [fill=red!40, draw=none] table [x=size, y=max] {\loadedtable} \closedcycle;
\addplot [fill=green!40, draw=none] table [x=size, y=med] {\loadedtable} \closedcycle;
\addplot [draw=black, line legend] table [x=size, y=med] {\loadedtable};
\addplot [fill=white, draw=white] table [x=size, y=min] {\loadedtable} \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}