1

This question asks how to match coordinate systems in PGFplots from ordered pair to ordered pair. What I would like to do, is mix coordiante systems within an ordered pair, for eaxmple, use axis cs for x, and rel axis cs for y. How would I do so?

\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 Answers1

2

This can be done using the -| or |- operators inside the coordinate itself. For details please have a look at the commenting text in the code.

\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}

image showing the result of above code

Stefan Pinnow
  • 29,535