1

I am trying to create a plot using an external graphic. The problem is that the axis extents are very different, so I need to use the unit vector (1,300). When I try to compile, I get the following error:

! Dimension too large.
<recently read> \pgfmath@x 
l.23 \end{axis}

How can I convince pgfplots to do the job without manually fiddling with the scaling and the y tick labels?

Here is my code:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  enlargelimits=false,
  axis on top,
  xlabel={$y$},
  ylabel={$x$},
  unit vector ratio*=1 300,
  width=15cm,
  tick align=outside,
  x dir=reverse,
]
\addplot graphics [xmin=5,xmax=-5,ymin=33.119,ymax=33.124] {img.png};
\end{axis}
\end{tikzpicture}
\end{document}

This is the file img.png: img.png

0

Adjust height instead of unit vector ratio.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  enlargelimits=false,
  axis on top,
  xlabel={$y$},
  ylabel={$x$},
  %unit vector ratio*=1 300,
  width=15cm,
  height=3cm,
  tick align=outside,
  ytick=\empty,   %% y tick doesn't make sense for such a graph
  x dir=reverse,
]
\addplot graphics [xmin=5,xmax=-5,ymin=33.119,ymax=33.124] {img.png};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2
  • But don't the height / width values include axes, labels and so forth? So how do I set the aspect ratio of just the plot area?
    – sven
    Oct 8 '15 at 15:04
  • Hmm, well I guess the precise aspect ratio is not that important in my application, so I'm gonna accept the answer. It would be interesting, though, to see if there is another solution?
    – sven
    Oct 8 '15 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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