![绘制外部图形时尺寸太大](https://linux22.com/image/320464/%E7%BB%98%E5%88%B6%E5%A4%96%E9%83%A8%E5%9B%BE%E5%BD%A2%E6%97%B6%E5%B0%BA%E5%AF%B8%E5%A4%AA%E5%A4%A7.png)
我正在尝试使用外部图形创建一个图。问题是轴范围非常不同,所以我需要使用单位向量 (1,300)。当我尝试编译时,出现以下错误:
! Dimension too large.
<recently read> \pgfmath@x
l.23 \end{axis}
我怎样才能说服 pgfplots 完成这项工作,而无需手动摆弄缩放和 y 刻度标签?
这是我的代码:
\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}
答案1
调整height
而不是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}