尝试放大图表的一部分,但一直出现错误。不知道哪里出错了。如能提供任何帮助,我将不胜感激。
错误弹出:
尺寸太大。\pgf@xx \end{loglogaxis}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{spy}
\begin{document}
\centering
\begin{tikzpicture}[spy using outlines=
{circle, magnification=4, connect spies}]
\begin{loglogaxis}[x post scale=2, y post scale=1.5,xlabel=Reynolds Number,ylabel=Ohnesorge number, xmin=10^0, xmax=10^5, ymin=10^-3, ymax=10^1, grid=major, grid=minor]
\addlegendentry{1/4 Lift}
\addplot[color=black, mark=x, only marks] coordinates{
(6485.41491, 0.003317065)
(7927.942858, 0.003317065)
(8663.115504, 0.003317065)
(9219.462371, 0.003317065)
(9537.374867, 0.003317065)
(10491.11235, 0.003317065)
(11087.19828, 0.003317065)
(12219.76155, 0.003317065)
};
\addlegendentry{1/2 Lift}
\addplot[color=yellow, mark=o, only marks] coordinates{
(6556.945221, 0.003317065)
(7868.334265, 0.003317065)
(8663.115504, 0.003317065)
(9187.671122, 0.003317065)
(9120.114717, 0.003317065)
(10443.42548, 0.003317065)
(11683.28421, 0.003317065)
(12875.45607, 0.003317065)
};
\coordinate (spypoint) at (10^4,10^-2);
\coordinate (magnifyglass) at (10^2,10^-1);
\end{loglogaxis}%
\spy [blue, size=1.5cm] on (spypoint)
in node[fill=white] at (magnifyglass);
\end{tikzpicture}%
\caption{Oh vs Re for straight nozzle}
\end{document}
答案1
添加axis cs:
到坐标,即写入
\coordinate (spypoint) at (axis cs:10^4,10^-2);
\coordinate (magnifyglass) at (axis cs:10^2,10^-1);
如果没有此前缀,tikz 会尝试将spypoint
原点定位在东边 10000 厘米处和北边 0.01 厘米处。如果使用此前缀,tikz 会将给定的坐标转换为与绘图坐标相同的方式,这里甚至是对数方式。(cs 代表坐标系。)
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{spy}
\begin{document}
\centering
\begin{tikzpicture}[spy using outlines=
{circle, magnification=4, connect spies}]
\begin{loglogaxis}[x post scale=2, y post scale=1.5,xlabel=Reynolds Number,ylabel=Ohnesorge number, xmin=10^0, xmax=10^5, ymin=10^-3, ymax=10^1, grid=major, grid=minor]
\addlegendentry{1/4 Lift}
\addplot[color=black, mark=x, only marks] coordinates{
(6485.41491, 0.003317065)
(7927.942858, 0.003317065)
(8663.115504, 0.003317065)
(9219.462371, 0.003317065)
(9537.374867, 0.003317065)
(10491.11235, 0.003317065)
(11087.19828, 0.003317065)
(12219.76155, 0.003317065)
};
\addlegendentry{1/2 Lift}
\addplot[color=yellow, mark=o, only marks] coordinates{
(6556.945221, 0.003317065)
(7868.334265, 0.003317065)
(8663.115504, 0.003317065)
(9187.671122, 0.003317065)
(9120.114717, 0.003317065)
(10443.42548, 0.003317065)
(11683.28421, 0.003317065)
(12875.45607, 0.003317065)
};
\coordinate (spypoint) at (axis cs:10^4,10^-2);
\coordinate (magnifyglass) at (axis cs:10^2,10^-1);
\end{loglogaxis}%
\spy [blue, size=1.5cm] on (spypoint)
in node[fill=white] at (magnifyglass);
\end{tikzpicture}%
\end{document}