2

I would like to access the x- and y-Coordinate of an intersection, outside of the axis environment. This is what I believed would solve my problem, based on this and this:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\begin{axis}%[xmin=0,xmax=1]
\addplot [color=blue, mark=none,domain=0:1, name path global=blau] {x};
\addplot [color=red, mark=none,domain=0:1, name path global=rot] {1-x};
\path [name intersections={of=blau and rot,by=inter}];
\path let \p1=(inter) in node[] () at (\x1,\y1);
\end{axis}

\node[color=black] () at (\x1, 0) {Access Demonstration x};
\node[color=black] () at (0, \y1) {Access Demonstration y};

\end{tikzpicture}

\end{document}

Thank you for your help.

2

You need to load intersections and no, this method won't work since \x1 and \y1 are not known where you want to use them. However, there is an even simpler way.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
\begin{axis}%[xmin=0,xmax=1]
\addplot [color=blue, mark=none,domain=0:1, name path global=blau] {x};
\addplot [color=red, mark=none,domain=0:1, name path global=rot] {1-x};
\path [name intersections={of=blau and rot,by=inter}];

\end{axis}

\node[color=black] () at (inter|-0,0) {Access Demonstration x};
\node[color=black] () at (inter-|0,0) {Access Demonstration y};

\end{tikzpicture}

\end{document}

enter image description here

2
  • So what is the \pgfplotsset{compat=1.16} about?
    – Hiwi Makro
    Nov 9 '18 at 14:05
  • 1
    @HiwiMakro It sets the version to be 1.16.
    – user121799
    Nov 9 '18 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.