pgfplots 底部的文本损坏

pgfplots 底部的文本损坏

我正在使用下面的代码创建一个图表。底部有两个括号,分别表示 $t_1$ 和 $t_2$。但是数字 1 和 2 坏了(下部未显示)。我的代码有什么问题?我也尝试过解决这个问题,但\pgfplotsextra毫无效果。

另外,与下面的代码相关,我想把.style所有图表都放大到固定距离, IE1 厘米如果我理解了这个问题使用符号坐标时按绝对值放大限值对吧,这根本就不可能吧?

\documentclass[12pt,a7paper,landscape]{scrartcl}
\usepackage{pgfplots}

\pgfplotsset{standard/.style={axis x line=middle,axis y line=middle,every axis x label/.style={at={(current axis.right of origin)},anchor=north},every axis y label/.style={at={(current axis.above origin)},anchor=east}}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[standard,width=8cm,height=5cm,enlarge x limits=0.11,enlarge y limits=0.19,xlabel=$t$,ylabel=$v$,xtick={20,60},xticklabels={,},ytick={25},yticklabels={$v'$}]

\addplot[thick,color=black] coordinates { (0,0) (20,25) (60,25) };
\addplot[dashed,very thin,color=black] coordinates { (20,0) (20,25) (0,25) };
\addplot[dashed,very thin,color=black] coordinates { (60,0) (60,25) };

\node at (axis cs:13.3,8.3) {$s_1$};
\node at (axis cs:40,12.5) {$s_2$};

\draw [decorate,decoration={brace,mirror,raise=2pt}] (axis cs:0,0) -- (axis cs:20,0) node [midway,below=1pt] {$t_1$};
\draw [decorate,decoration={brace,mirror,raise=2pt}] (axis cs:20,0) -- (axis cs:60,0) node [midway,below=1pt] {$t_2$};

\end{axis} 
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

文本在轴区域的边缘被剪裁。为了防止这种情况,您可以clip=falseaxis选项提供键,或者将\draw命令放在after end axis/.code={...}在剪裁范围之外绘制注释的位置:

\documentclass[12pt,a7paper,landscape]{scrartcl}
\usepackage{pgfplots}

\pgfplotsset{standard/.style={axis x line=middle,axis y line=middle,every axis x label/.style={at={(current axis.right of origin)},anchor=north},every axis y label/.style={at={(current axis.above origin)},anchor=east}}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    standard,
    width=8cm,height=5cm,
    enlarge x limits=0.11,enlarge y limits=0.19,
    xlabel=$t$,ylabel=$v$,
    xtick={20,60},xticklabels={,},
    ytick={25},yticklabels={$v'$},
    after end axis/.code={
        \draw [decorate,decoration={brace,mirror,raise=2pt}] (axis cs:0,0) -- (axis cs:20,0) node [midway,below=1pt] {$t_1$};
        \draw [decorate,decoration={brace,mirror,raise=2pt}] (axis cs:20,0) -- (axis cs:60,0) node [midway,below=1pt] {$t_2$};
    }
]

\addplot[thick,color=black] coordinates { (0,0) (20,25) (60,25) };
\addplot[dashed,very thin,color=black] coordinates { (20,0) (20,25) (0,25) };
\addplot[dashed,very thin,color=black] coordinates { (60,0) (60,25) };

\node at (axis cs:13.3,8.3) {$s_1$};
\node at (axis cs:40,12.5) {$s_2$};

\end{axis} 
\end{tikzpicture}
\end{document}

相关内容