Drawing a box with shading in pgfplots

As a follow-up to this question, or more precisely this answer, I'd like to know how to do the equivalent of

\shadedraw
(2,0) -- (2,1)
{[rounded corners=1em] -- (3,1)} --
(3,0) -- (2,0);


using pgfplots such that the shading is done in the CMYK colorspace.

(This would then be used in baposter as a replacement for the shading in the headers of the boxes.)

• May I ask why you insist on CMYK model for a poster? You can ask for the CMYK version from the printer if you feel there will be a significant difference. In Photoshop (if you have it) there was a Gamut Warning thingy when I was keen on using Adobe stuff. That can tell you if there will be a significant problem by turning the areas in the gray. – percusse Oct 10 '13 at 8:43
• The reason is that I have a shading from white to light gray in the background. I cannot predict what this would look like in print if it's converted from RGB to CMYK, so I'd prefer to use CMYK. – fuenfundachtzig Oct 10 '13 at 10:17

As already stressed in https://tex.stackexchange.com/a/137031, this answer should be considered a workaround: the correct solution would be to "wait for the feature request in tikz".

Naturally, that can take longer than having a clumsy work-around at hand.

Here is an attempt to use a pgfplots surface plot to simulate your desired filled shading:

\documentclass[a4paper]{article}

\usepackage[cmyk]{xcolor}

\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
% if you have v1.8, write:
%\pgfplotsset{mesh/colorspace explicit color output=cmyk}

\begin{document}

\begin{tikzpicture}
\draw (0,0) grid (3,3);
(2,0) -- (2,1)
{[rounded corners=1em] -- (3,1)} --
(3,0) -- (2,0);
\end{tikzpicture}

\begin{tikzpicture}

\draw (0,0) grid (3,3);
\draw
[color=blue,line width=4pt]
(2,0) -- (2,1)
{[rounded corners=1em] -- (3,1)} --
(3,0) -- cycle;
\clip
(2,0) -- (2,1)
{[rounded corners=1em] -- (3,1)} --
(3,0) -- cycle;

\begin{axis}[
% necessary to match up coordinate systems:
xmin=0,ymin=0,
anchor=origin,
x=1cm,y=1cm,
hide axis,
]
table[meta=cdata] {
x y cdata
2 0 color=green
2 1 color=green

3 0 color=orange
3 1 color=orange
};
\end{axis}
\end{tikzpicture}
\end{document}


Both are tikzpictures, the first one is replicated from your question and the second one is based on pgfplots. You see that it is considerably more involved: it installs a clip path to restrict the shading to your "rounded" rectangle, then it draws the outline of the clip path (for some reason, pgf rejects it if I say \draw[clip] with the remaining options). The rest is a pgfplots axis which is forced to use the same coordinate system as the outer tikz picture (requiring a bunch of keys explained in section "TikZ interoperability" in the pgfplots manual).