Following the first tutorial in the TikZ manual, I tend to take steps to improve the legibility of tick labels when placed over gridlines. I prefer to use a fading rather than a plain white rectangle. However, if two nodes with faded background get placed right next to each other, one will "fade" over the text of the other. Putting them all in a transparency group just seems to kill the fading effect altogether.
How do I make the fadings in two overlapping nodes not act on each other's text? (Preventing their fadings from stacking would be nice also, but is less important.)
Unfortunately, I was unsuccessful in uploading images that demonstrate the transparency, but here's the code for some minimal working examples:
What it's supposed to look like, more or less:
\documentclass[tikz]{standalone}
%
%With the following code (from the TikZ manual) installed,
%the option "path fading=fade out"
%will cause a filled shape or node to be opaque in the center and
%gradually fade to transparency at the edges.
\usetikzlibrary{fadings}
\tikzfading[name=fade out,
inner color=transparent!0,
outer color=transparent!100]
%
\begin{document}
\begin{tikzpicture}[scale=1.0]
\draw[help lines] (-4.9,-4.9) grid (4.9,4.9);
\draw[thin,->] (-5,0) -- (5,0) node[right]{$x$};
\draw[thin,->] (0,-5) -- (0,5) node[above]{$y$};
\begin{scope}[ticklabel/.style={fill=white,path fading=fade out,text opacity=1.0}]
\foreach \x in {-4,-3,-2,-1,1,2,3,4}
{
\node[below,ticklabel] at (\x,0) {$\x$};
}
\foreach \y in {-4,-3,-2,-1,1,2,3,4}
{
\node[left,ticklabel] at (0,\y) {$\;\y$};
}
\end{scope}
\end{tikzpicture}
\end{document}
What it looks like when nodes are too close together, with background rectangles to help illustrate the effect:
\documentclass{standalone}
\usepackage{tikz}
%
%With the following code (from the TikZ manual) installed,
%the option "path fading=fade out"
%will cause a filled shape or node to be opaque in the center and
%gradually fade to transparency at the edges.
\usetikzlibrary{fadings}
\tikzfading[name=fade out,
inner color=transparent!0,
outer color=transparent!100]
%
\begin{document}
\begin{tikzpicture}[scale=0.4]
\fill[black!20] (-5,-5) rectangle (5,5);
\draw[help lines] (-4.9,-4.9) grid (4.9,4.9);
\draw[thin,->] (-5,0) -- (5,0) node[right]{$x$};
\draw[thin,->] (0,-5) -- (0,5) node[above]{$y$};
\begin{scope}[ticklabel/.style={fill=white,path fading=fade out,text opacity=1.0}]
\foreach \x in {-4,-3,-2,-1,1,2,3,4}
{
\node[below,ticklabel] at (\x,0) {$\x$};
}
\foreach \y in {-4,-3,-2,-1,1,2,3,4}
{
\node[left,ticklabel] at (0,\y) {$\y$};
}
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[scale=0.4]
\fill[black!20] (-5,-5) rectangle (5,5);
\draw[help lines] (-4.9,-4.9) grid (4.9,4.9);
\draw[thin,->] (-5,0) -- (5,0) node[right]{$x$};
\draw[thin,->] (0,-5) -- (0,5) node[above]{$y$};
\begin{scope}[ticklabel/.style={fill=white,path fading=fade out,text opacity=1.0},transparency group]
\foreach \x in {-4,-3,-2,-1,1,2,3,4}
{
\node[below,ticklabel] at (\x,0) {$\x$};
}
\foreach \y in {-4,-3,-2,-1,1,2,3,4}
{
\node[left,ticklabel] at (0,\y) {$\y$};
}
\end{scope}
\end{tikzpicture}
\end{document}
The example on the right shows the effect of putting the nodes inside a transparency group.