Extract the x/y part from a coordinate in pgfplots
I'm not aware of any direct syntax to do that (though I would love to have one). You can however use the let
operation (section 14.15 in the TikZ v2.10 manual):
\usetikzlibrary{calc}
[...]
\draw let \p1 = (A) in (\x1,3) -- (0,0);
For the second part of your question: You can do that with the |-
syntax.
\coordinate (A) at (1,2);
\draw (A |- 0,3) -- (0,0);
Note that for pgfplots you need to set the version to at least 1.11 (e.g., \pgfplotsset{compat=1.11}
or \pgfplotsset{compat=newest}
) or use coordinates in the (axis cs:x,y)
format for the intended behaviour.