无需明确设置 x 域键domain
,如何将装饰路径剪裁到视口 y 限制,ymin = 0.5, ymax = 2.5
以便\pgfdecoratedpathlength
在屏幕上进行测量?
换句话说,text align = {left indent = {0.75\dimexpr\pgfdecoratedpathlength\relax}}
应该将文字排版text
在靠近右下角的位置。
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text, math, intersections}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymin = 0.5, ymax = 2.5,
]
%
\addplot [
variable = \Fbr,
postaction = {
decoration = {
text along path,
text = {text},
text align = {left indent = {0.75\dimexpr\pgfdecoratedpathlength\relax}},
}, decorate,
},
] {1 - \Fbr};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
如果您使用clip=false
、 和standalone
,您可以看到文本的位置:
使用默认域 (-5:5) 构建线,然后进行剪辑。
也许你想要以下内容(我限制了情节的范围):
\documentclass{standalone}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\usetikzlibrary{decorations.text, math, intersections}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymin = 0.5, ymax = 2.5,
domain = -1.5:0.5,
% clip=false,
]
%
\addplot [
variable = \Fbr,
postaction = {
decoration = {
text along path,
text = {text},
text align = {left indent = {0.75\dimexpr\pgfdecoratedpathlength\relax}},
}, decorate,
},
] {1 - \Fbr};
\end{axis}
\end{tikzpicture}
\end{document}
或者,如果您只想指定垂直域,让其余部分单独存在,您应该绘制使用 y 作为变量:
\documentclass{standalone}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\usetikzlibrary{decorations.text, math, intersections}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain = 2.5:0.5,
]
%
\addplot [
variable = \Fbr,
postaction = {
decoration = {
text along path,
text = {text},
text align = {left indent = {0.75\dimexpr\pgfdecoratedpathlength\relax}},
}, decorate,
},
] ({1 - \Fbr}, \Fbr);
\end{axis}
\end{tikzpicture}
\end{document}
...但是你需要一个域;它是pgfplots
迭代查找功能点的地方。
PD:我想您的只是一个例子,您使用装饰是因为您在更复杂的情节中需要它们,否则:
\documentclass{standalone}
\usepackage{pgfplots}\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
domain = 2.5:0.5,
]
%
\addplot [variable=\Fbr] ({1 - \Fbr}, \Fbr) node[above, sloped, pos=0.75]{text};
\end{axis}
\end{tikzpicture}
\end{document}
给出几乎相同的输出: