我正在使用下面的程式碼來建立圖表。底部有兩個大括號,表示為 $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=false
的鍵axis
,或將\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}