从轴环境连接节点并使用/tikz/scale 时出现问题

从轴环境连接节点并使用/tikz/scale 时出现问题

考虑一下这个近似 MWE:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\begin{document}

\begin{tikzpicture}[]
\begin{axis}[clip=false,
    width=12cm, height=12cm,
    xmin=0, xmax=10,
    ymin=-1, ymax=11,
    grid=both,
    major grid style={black!50, dashed},
    ytick={-1,...,11},
    xlabel = {input voltage $E$ (V)},
    ylabel = {output voltage $v_o$ (V)}, % clip=false,
] 
\draw [thick, ->] (axis cs: 0,0) -- (axis cs: 10,0) node[below left] {$E$};  
\draw [ultra thick, color=blue, draw opacity=0.5] (axis cs: 0, 10) -- (axis cs: 0.7, 10) -- (axis cs: 1.6, 0.9) -- (axis cs: 10,9.3);
\draw[ultra thick, color=blue, ->] (axis cs: 4,3.5) -- node [above]{$v_o$} (axis cs: 3,3.5);
\fill [black!50, fill opacity=0.5] (axis cs: 0, 10.5) rectangle node[black](off){A} (axis cs:0.7, 11);
\fill [green!50, fill opacity=0.5] (axis cs: 0.7, 10.5) rectangle node[black](lin){B} (axis cs:1.6, 11);
\fill [red!50, fill opacity=0.5] (axis cs: 1.6, 10.5) rectangle node[black](sat){C} (axis cs:10, 11);
\end{axis}
\path (2,13) node[rectangle, draw](off text){OFF zone};
\path (4.5,12) node[rectangle, draw](lin text){LINear zone};
\path (7,11) node[rectangle, draw](sat text){SATuration zone};
\path [<-] (off.center) edge[bend left] (off text.west);
\path [<-] (lin.center) edge[bend left] (lin text.west);
\path [<-] (sat.center) edge[bend left] (sat text.west);
\end{tikzpicture}
\end{document}

它给出了正确的输出 --- 我知道节点的位置(sat)并不理想,但我将在理解这个谜题后解决这个问题:

图形好

问题是,如果我添加[scale=0.8]到主tikzpicture环境,将发生以下情况(摘录图纸的上部,以节省空间):

图形不佳

就好像,虽然节点移动正确(参见彩色带中的 A、B、C 标签),但当我尝试将节点从轴内部连接到外部时,会发生故障。

我想,这和以往一样,是操作员的错误...但哪一个呢?能轻松修复吗?

PS --- 我使用的是 Ubuntu 14.04,带有 TeXLive2013,最大pfgcompat可接受尺寸是1.9

PPS(稍后)---我可以用axis cs:坐标来表达所有内容,但这只有在以下情况下才有效clip=false;如果我需要剪辑轴环境,则该方法将不起作用。

答案1

我认为这些问题是由不同的坐标系统引起的。因此,我将\path命令移入环境中axis并稍微调整了它们的位置。

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}
\begin{document}

\begin{tikzpicture}[scale=0.8]
\begin{axis}[clip=false,
    width=12cm, height=12cm,
    xmin=0, xmax=10,
    ymin=-1, ymax=11,
    grid=both,
    major grid style={black!50, dashed},
    ytick={-1,...,11},
    xlabel = {input voltage $E$ (V)},
    ylabel = {output voltage $v_o$ (V)}, 
] 
\draw [thick, ->] (axis cs: 0,0) -- (axis cs: 10,0) node[below left] {$E$};  
\draw [ultra thick, color=blue, draw opacity=0.5] (axis cs: 0, 10) -- (axis cs: 0.7, 10) -- (axis cs: 1.6, 0.9) -- (axis cs: 10,9.3);
\draw[ultra thick, color=blue, ->] (axis cs: 4,3.5) -- node [above]{$v_o$} (axis cs: 3,3.5);
\fill [black!50, fill opacity=0.5] (axis cs: 0, 10.5) rectangle node[black](off){A} (axis cs:0.7, 11);
\fill [green!50, fill opacity=0.5] (axis cs: 0.7, 10.5) rectangle node[black](lin){B} (axis cs:1.6, 11);
\fill [red!50, fill opacity=0.5] (axis cs: 1.6, 10.5) rectangle node[black](sat){C} (axis cs:10, 11);
\path (axis cs: 2,13) node[rectangle, draw](off text){OFF zone};
\path (axis cs: 3.5,12) node[rectangle, draw](lin text){LINear zone};
\path (axis cs: 7,12) node[rectangle, draw](sat text){SATuration zone};
\path [<-] (off.center) edge[bend left] (off text.west);
\path [<-] (lin.center) edge[bend left] (lin text.west);
\path [<-] (sat.center) edge[bend left] (sat text.west);
\end{axis}

\end{tikzpicture}
\end{document}

现在scale密钥可以按预期工作了(0.8vs 1.5):

在此处输入图片描述

相关内容