Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm sure this question has a simple answer that I'm missing: I'm trying to use pgfplots to put two graphs right next to each other with no space in between. I thought I could do this by using the \pgfresetboundingbox command found in the manual. However, LaTeX gives me an undefined control sequence error on this command. What am I doing wrong?

\begin{tikzpicture}
\begin{axis}[
ylabel={$\hat{\delta}$},
xlabel={$x$}
]
\addplot table[x index=0, y index=2, header=false]{probset1.txt};
\end{axis}
\pgfresetboundingbox
\end{tikzpicture}
\hspace{0cm}
\begin{tikzpicture}
\begin{axis}[
xlabel={$x$},
ytick=\empty
]
\addplot table[x index=0, y index=3, header=false]{probset1.txt};
\end{axis}
\end{tikzpicture}
share|improve this question
    
Welcome to TeX.SX. Please add a complete, compilable but minimal example that illustrates your problem. –  Martin Scharrer Mar 17 '11 at 2:21
    
Would be nice with a compilable example. However, with some dummy data your example compiles fine for me, perhaps you need to update PGF/PGFPLOTS. It doesn't give the output you wanted though, but what about removing the \pgfresetboundingbox and adding some negative hspace? Not ideal, but it may work. –  Torbjørn T. Mar 17 '11 at 2:21
add comment

1 Answer

Two approaches:

  1. Include the axes in the same tikzpicture and place them using the axis nodes south east and south west, which lie on the corners of the axes.
  2. Reset the bounding box as you suggested (probably after updating your pgf), then set the axis as the new bounding box.

Here's example code for both methods:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[anchor=south east,
width=5cm,
ylabel={$\hat{\delta}$},
xlabel={$x$}
]
\addplot coordinates {(1,1) (2,1.5)};
\end{axis}
\begin{axis}[anchor=south west,
width=5cm,
xlabel={$x$},
ytick=\empty
]
\addplot coordinates {(1,1.4) (2,1.1)};
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[
width=5cm,
ylabel={$\hat{\delta}$},
xlabel={$x$}
]
\addplot coordinates {(1,1) (2,1.5)};
\end{axis}\pgfresetboundingbox
\useasboundingbox
(current axis.below south west)
rectangle (current axis.north east);
\end{tikzpicture}%
\begin{tikzpicture}
\begin{axis}[
width=5cm,
xlabel={$x$},
ytick=\empty
]
\addplot coordinates {(1,1.4) (2,1.1)};
\end{axis}
\end{tikzpicture}
\end{document}

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.