Dear Jan,

good point, your use-case is currently undocumented.

You can use the tikz library "backgrounds" to draw backgrounds of an axis: provide the two relevant options "background rectangle/.style={fill=white}" and "show background rectangle" to your axis to enable them (and include the tikz library). Due to technical reasons, you need to write '/tikz/background rectangle/.style={}'. See the first tikzpicture in the attached example.

There is also a different approach which might be of interest, so I took the freedom to provide a "see also" answer to your question: you may want to use \node[pin = ...] from tikz. Since I am not sure if you want this approach, I have just included it in the attached example -- the reference how this is done is the tikz manual. In principle, you write
\node[pin=<angle>:<label text>] {};
In my case, I chose <angle>=45 and <label text> = a complete tikz picture with an axis inside of it. Furthermore, I provided additional drawing options for the pin using the pin={[<options>]<angle>:<label text>} syntax of tikz. Please refer to tikz for more information.

Finally, there is one more "see also" answer which might be interesting (although it is not precisely what you asked for): The pgfplots "axis background" style allows to fill everything *without* ticks and descriptions; see the third picture in the attached example.

Best regards

Christian

Am 04.02.2011 16:12, schrieb Jan Lotichius:
Hello everyone,

I want to fill the background of a complete axis-environment, including ticks and labels and everything. I see that this is done in the manual via a colorbox. But this does not work anymore if you position the axis environment using at=somewhere.

Find an example below. As you can see, fill=white for the second plot would be handy to cover the grid of the first plot. Any ideas how to do this?

Here is the example:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[grid=both]
        \addplot coordinates{
                            (0,1)
                            (1,1)
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)
                            (2,1)
                            (3,1)
                            (3.5,3)
                            (4,5)};
        \node (Zoom) at (axis cs:1.2,2)[coordinate]{};
    \end{axis}
\begin{axis}[tiny, grid=both, at=(Zoom), anchor=south west, fill=white] %fill does not work!
        \addplot coordinates{
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)};
    \end{axis}
\end{tikzpicture}
\end{document}

Regards,
Jan


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb


_______________________________________________
Pgfplots-features mailing list
Pgfplots-features@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgfplots-features

\documentclass[a4paper]{article}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\usetikzlibrary{backgrounds}


\begin{document}
\begin{tikzpicture}
    \begin{axis}[grid=both]
        \addplot coordinates{
                            (0,1)
                            (1,1)
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)
                            (2,1)
                            (3,1)
                            (3.5,3)
                            (4,5)};
        \node (Zoom) at (axis cs:1.2,2)[coordinate]{};
    \end{axis}
    \begin{axis}[tiny, grid=both, at=(Zoom), anchor=south west, /tikz/background rectangle/.style={fill=yellow},show background rectangle]
        \addplot coordinates{
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)};
    \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
    \begin{axis}[grid=both]
        \addplot coordinates{
                            (0,1)
                            (1,1)
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)
                            (2,1)
                            (3,1)
                            (3.5,3)
                            (4,5)};
        \node (Zoom) at (axis cs:1.2,2)[coordinate]{};
    \end{axis}
    \begin{axis}[tiny, grid=both, at=(Zoom), anchor=south west, axis background/.style={fill=yellow}]
        \addplot coordinates{
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)};
    \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
    \begin{axis}[grid=both]
        \addplot coordinates{
                            (0,1)
                            (1,1)
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)
                            (2,1)
                            (3,1)
                            (3.5,3)
                            (4,5)};
        \node (Zoom) at (axis cs:1.2,2)[coordinate]{};
    \end{axis}
	\node[at=(Zoom),fill=yellow,pin={[fill=green]45:{%
	\begin{tikzpicture}[baseline]
    \begin{axis}[tiny, grid=both, anchor=south west]
        \addplot coordinates{
                            (1.2,1)
                            (1.3,1.01)
                            (1.4,0.95)
                            (1.5,1)};
    \end{axis}
	\end{tikzpicture}}}] {};
\end{tikzpicture}


\end{document}

Attachment: P.pdf
Description: Adobe PDF document

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Pgfplots-features mailing list
Pgfplots-features@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgfplots-features

Reply via email to