y 标签中的数学类型重复;出现重影线

y 标签中的数学类型重复;出现重影线

当我运行下面的代码时,我想要的图表被创建了,但存在两个问题:

  1. 底部有一条奇怪的灰线,我无法找到并删除
  2. y 标签的数学类型在原点附近重复。

如果你能弄清楚为什么会发生这种情况以及如何阻止它,我将不胜感激。

谢谢。

\documentclass[twocolumn]{revtex4}
\usepackage{amsfonts,amssymb,amsmath,mathbbol,graphics,graphicx,epsfig,ulem,epstopdf,pgfplots,xfrac}
\pgfplotsset{compat=1.9}

\begin{document}

\begin{figure}
\begin{tikzpicture}[trim left=-7]
\begin{axis}[width=9cm,axis x line=box, axis y line=box, tick align=outside, enlargelimits=true, xlabel={Separation of Charges, cm}, ylabel={F$_E^{-\sfrac{1}{2}}$, N}, ylabel,  yticklabel style={/pgf/number format/fixed,/pgf/number format/fixed zerofill,/pgf/number format/precision=0,scaled ticks=false}, style={yshift=-0.2cm}, axis line style={-}, tick pos=left, legend pos=north west]
\addplot[only marks, mark=x, color=olive] coordinates {
    (4.55,16.91774221)
    (4.65,15.82338302)
    (4.65,16.02527474)
    (4.85,15.26061779)
    (4.85,15.62893444)
    (4.85,15.82338302)
    (4.95,15.62893444)
    (4.95,16.02527474)
    (5.35,18.27589266)
    (5.95,20.43824264)
    (5.95,20.87897442)
    (6.55,21.34950572)
    (6.55,21.85335349)
    (7.35,25.04749438)
    (8.35,27.79990209)
    (8.35,30.23455951)
};
\addlegendentry{One occurence}
\addplot[only marks, mark=x, color=cyan] coordinates {
    (4.55,17.16516758)
    (4.55,17.42377643)
    (4.75,16.45338269)
    (4.85,15.44148262)
    (5.15,16.45338269)
    (5.35,18.58897266)
    (5.35,18.91871426)
};
\addlegendentry{Two occurences}
\addplot[only marks, mark=x, color=orange] coordinates {
    (4.65,16.23509691)
    (4.75,16.02527474)
    (4.95,15.82338302)
    (5.15,16.68071682)
    (5.95,21.34950572)
    (6.55,22.39464462)
    (8.35,28.94070541)
};
\addlegendentry{Three occurences}
\addplot[only marks, mark=x, color=purple] coordinates {
    (7.35,25.87222104)
};
\addlegendentry{Four occurences}
\addplot[only marks, mark=x, color=black, error bars/.cd, x dir=both, x explicit] coordinates {
    (4.65,16.10822318) +- (0.2,0)
    (4.75,16.19247315) +- (0.2,0)
    (4.85,15.51565074) +- (0.2,0)
    (4.95,15.82338302) +- (0.2,0)
    (5.15,16.58865761) +- (0.2,0)
    (5.35,18.65354171) +- (0.2,0)
    (5.95,21.06342629) +- (0.2,0)
    (6.55,22.06512210) +- (0.2,0)
    (7.35,25.70075935) +- (0.2,0)
    (8.35,28.94070541) +- (0.2,0)
};
\addlegendentry{Average}
\addplot[only marks, mark=x, color=gray, error bars/.cd, x dir=both, x explicit] coordinates {
    (4.55,17.21596818) +- (0.2,0)
};
\addlegendentry{Unused}
\addplot[domain=4.55:8.35] {3.70070829*x-1.76190677};
\coordinate (pt) at (axis cs:6.45,12.55);
\draw [black] (axis cs:4.5,15.05) rectangle (axis cs:5.2,17.65);
\draw [dashed] (axis cs:5.2,15.05) -- (axis cs:6.82,14.38);
\draw [dashed] (axis cs:5.2,17.65) -- (axis cs:6.82,19.89);
\end{axis}
\node[pin=70:{%
    \begin{tikzpicture}
    \begin{axis}[tiny, xmin=4.5,xmax=5.2, ymin=15.05,ymax=17.65, enlargelimits=false, ylabel near ticks, yticklabel pos=right, xlabel near ticks, xticklabel pos=upper, xtick={4.55,4.75,4.95,5.15}]
    \addplot[only marks, mark=x, color=olive] coordinates {
        (4.55,16.91774221)
        (4.65,15.82338302)
        (4.65,16.02527474)
        (4.85,15.26061779)
        (4.85,15.62893444)
        (4.85,15.82338302)
        (4.95,15.62893444)
        (4.95,16.02527474)
    };
    \addplot[only marks, mark=x, color=cyan] coordinates {
        (4.55,17.16516758)
        (4.55,17.42377643)
        (4.75,16.45338269)
        (4.85,15.44148262)
        (5.15,16.45338269)
    };
    \addplot[only marks, mark=x, color=orange] coordinates {
        (4.65,16.23509691)
        (4.75,16.02527474)
        (4.95,15.82338302)
        (5.15,16.68071682)
    };
    \addplot[only marks, mark=x, color=black] coordinates {
        (4.55,17.21596818)
        (4.65,16.10822318)
        (4.75,16.19247315)
        (4.85,15.51565074)
        (4.95,15.82338302)
        (5.15,16.58865761)
    };
    \addplot[only marks, mark=x, color=gray] coordinates {
        (4.55,17.21596818)
    };
    \end{axis}
    \end{tikzpicture}%
}] at (pt) {};
\end{tikzpicture}
\caption{Plotted is all data taken over the course of the experiment.  The coloured crosses represent the number of times a particular force was recorded.  The black crosses, which are evenly split along the line of best fit as expected, denote the average at each separation.  The error bars were calculated as detailed in the Error Appendix.}
\label{fig:1}
\end{figure}

\end{document}

答案1

细灰线是由于您使用了pin。请label改用 。

数学的重复是来自虚假ylabel关键字(直接在正确的之后ylabel=<label text>)的产物。

\documentclass{article}
\usepackage{pgfplots, xfrac}
\pgfplotsset{compat=1.9}

\begin{document}

\begin{figure}
\begin{tikzpicture}[trim left=-7]
\begin{axis}[
    width=9cm,
    axis x line=box,
    axis y line=box,
    tick align=outside,
    enlargelimits=true,
    xlabel={Separation of Charges, cm},
    ylabel={$\mathrm{F}_E^{-\sfrac{1}{2}}$, N},
    yticklabel style={
        /pgf/number format/fixed,
        /pgf/number format/fixed zerofill,
        /pgf/number format/precision=0,
        scaled ticks=false
    },
    style={yshift=-0.2cm},
    axis line style={-},
    tick pos=left,
    legend pos=north west
]
\addplot[only marks, mark=x, color=olive] coordinates {
    (4.55,16.91774221)
    (4.65,15.82338302)
    (4.65,16.02527474)
    (4.85,15.26061779)
    (4.85,15.62893444)
    (4.85,15.82338302)
    (4.95,15.62893444)
    (4.95,16.02527474)
    (5.35,18.27589266)
    (5.95,20.43824264)
    (5.95,20.87897442)
    (6.55,21.34950572)
    (6.55,21.85335349)
    (7.35,25.04749438)
    (8.35,27.79990209)
    (8.35,30.23455951)
};
\addlegendentry{One occurence}
\addplot[only marks, mark=x, color=cyan] coordinates {
    (4.55,17.16516758)
    (4.55,17.42377643)
    (4.75,16.45338269)
    (4.85,15.44148262)
    (5.15,16.45338269)
    (5.35,18.58897266)
    (5.35,18.91871426)
};
\addlegendentry{Two occurences}
\addplot[only marks, mark=x, color=orange] coordinates {
    (4.65,16.23509691)
    (4.75,16.02527474)
    (4.95,15.82338302)
    (5.15,16.68071682)
    (5.95,21.34950572)
    (6.55,22.39464462)
    (8.35,28.94070541)
};
\addlegendentry{Three occurences}
\addplot[only marks, mark=x, color=purple] coordinates {
    (7.35,25.87222104)
};
\addlegendentry{Four occurences}
\addplot[only marks, mark=x, color=black, error bars/.cd, x dir=both, x explicit] coordinates {
    (4.65,16.10822318) +- (0.2,0)
    (4.75,16.19247315) +- (0.2,0)
    (4.85,15.51565074) +- (0.2,0)
    (4.95,15.82338302) +- (0.2,0)
    (5.15,16.58865761) +- (0.2,0)
    (5.35,18.65354171) +- (0.2,0)
    (5.95,21.06342629) +- (0.2,0)
    (6.55,22.06512210) +- (0.2,0)
    (7.35,25.70075935) +- (0.2,0)
    (8.35,28.94070541) +- (0.2,0)
};
\addlegendentry{Average}
\addplot[only marks, mark=x, color=gray, error bars/.cd, x dir=both, x explicit] coordinates {
    (4.55,17.21596818) +- (0.2,0)
};
\addlegendentry{Unused}
\addplot[domain=4.55:8.35] {3.70070829*x-1.76190677};
\coordinate (pt) at (axis cs:6.45,12.55);
\draw [black] (axis cs:4.5,15.05) rectangle (axis cs:5.2,17.65);
\draw [dashed] (axis cs:5.2,15.05) -- (axis cs:6.82,14.38);
\draw [dashed] (axis cs:5.2,17.65) -- (axis cs:6.82,19.89);
\end{axis}
\node[label=70:{%
    \begin{tikzpicture}
    \begin{axis}[tiny, xmin=4.5,xmax=5.2, ymin=15.05,ymax=17.65, enlargelimits=false, ylabel near ticks, yticklabel pos=right, xlabel near ticks, xticklabel pos=upper, xtick={4.55,4.75,4.95,5.15}]
    \addplot[only marks, mark=x, color=olive] coordinates {
        (4.55,16.91774221)
        (4.65,15.82338302)
        (4.65,16.02527474)
        (4.85,15.26061779)
        (4.85,15.62893444)
        (4.85,15.82338302)
        (4.95,15.62893444)
        (4.95,16.02527474)
    };
    \addplot[only marks, mark=x, color=cyan] coordinates {
        (4.55,17.16516758)
        (4.55,17.42377643)
        (4.75,16.45338269)
        (4.85,15.44148262)
        (5.15,16.45338269)
    };
    \addplot[only marks, mark=x, color=orange] coordinates {
        (4.65,16.23509691)
        (4.75,16.02527474)
        (4.95,15.82338302)
        (5.15,16.68071682)
    };
    \addplot[only marks, mark=x, color=black] coordinates {
        (4.55,17.21596818)
        (4.65,16.10822318)
        (4.75,16.19247315)
        (4.85,15.51565074)
        (4.95,15.82338302)
        (5.15,16.58865761)
    };
    \addplot[only marks, mark=x, color=gray] coordinates {
        (4.55,17.21596818)
    };
    \end{axis}
    \end{tikzpicture}%
}] at (pt) {};
\end{tikzpicture}
\caption{Plotted is all data taken over the course of the experiment.  The coloured crosses represent the number of times a particular force was recorded.  The black crosses, which are evenly split along the line of best fit as expected, denote the average at each separation.  The error bars were calculated as detailed in the Error Appendix.}
\label{fig:1}
\end{figure}

\end{document}

相关内容