这个问题询问如何将PGFplots
有序对中的坐标系与有序对中的坐标系进行匹配。我想要做的是,在有序对中混合坐标系,例如,axis cs
对x
和rel axis cs
对 分别使用y
。我该怎么做?
\documentclass{article}
\RequirePackage{tikz}
\usetikzlibrary{calc}
\RequirePackage{pgfplots}
\RequirePackage{pgffor}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[ hide axis,
scale only axis,
xmin=0,xmax=4,ymin=-0.5,ymax=1,
height=1cm,width=2cm,at={(0cm,0cm)}, clip=false]
\draw[red] (0,0) -- (1,1) -- (2,-0.5) -- (3,1) -- (4,0);
\node[anchor=north] at (rel axis cs: 0.5, 0) {min} ;
% \node[anchor=north] at ((axis cs: 2), (rel axis cs: 0)) {min} ; % no dice
% \node[anchor=north] at ({axis cs: 2}, {rel axis cs: 0}) {min} ; % no dice
\end{axis}
\end{tikzpicture}
\end{document}
答案1
这可以使用-|
或|-
运算符来完成里面坐标本身。有关详细信息,请查看代码中的注释文本。
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,xmax=4,
ymin=-0.5,ymax=1,
]
\node [
circle,
fill=red,
anchor=north,
label={[align=left]above:%
$x$ given in (absolute) ``axis coordinates'' and \\
$y$ given in ``relative axis coordinates''.\\
The given ``zeros'' are dummies and can be\\
arbitrary numbers.},
] at ({axis cs: 2,0} |- {rel axis cs: 0,0.25}) {};
\end{axis}
\end{tikzpicture}
\end{document}