I am trying to in a way automate the shading issue described here: Drawing a box with shading in pgfplots
The general goal is to put a working code part in my style definition using append after command.
But actually I am trying to find out how to solve some general problems.
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{scopes}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\draw[step=2ex,gray!20,thin] (-10ex,-7ex) grid (10ex, 7ex);
\node[draw, rectangle, rounded corners=6pt] at (0ex, 0ex) (md) {My Design};
\begin{pgfonlayer}{background}
\clip
(md.north west) [rounded corners=6pt] -- (md.north east)
-- (md.south east) --
(md.south west) -- cycle;
\newdimen\nwx
\pgfextractx{\nwx}{(cd.north west)}
\begin{axis}[
% necessary to match up coordinate systems:
xmin=-10ex,ymin=-7ex,
anchor=origin,
x=1ex,y=1ex,
hide axis,
]
\addplot[surf,mesh/color input=explicit,shader=interp]
table[meta=cdata] {
x y cdata
-6.5 2 color=gray!40
-6.5 -2 color=gray!40
5.5 2 color=white
5.5 -2 color=white
};
\end{axis}
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
As in the code above the clipping-part was somewhat easy to solve.
Now I have to change the plot accordingly. For this I need the x and y values of the used coordinates in the clip-part to insert them automatically and not manual.
Trying to use the let command in \addplot didn't work. So I tried to extract the values with \pgfextractx. But this brought me to another problem:
The result is given with the unit pt and produces an error. Additionally it would be nicer if I could use ex-values in the axis and don't have to change this to pt, because I think this could be an issue when I scale the graphics.
So is there a solution to convert the value to an ex unit and then remove the unit from the string?
Better solutions in general are also welcome! Thank you!
