# Adding extra ticks inside the axis environment

I am wondering if it is possible to add extra ticks to a plot without declaring them in the options of \begin{axis}. Consider the following example, where I would like to have the coordinates of the calculated point Ua appear on the graph.

\usepackage{tikz}
\usepackage[active,tightpage]{preview}  %generates a tightly fitting border around the work
\usepackage{pgfplots}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{2mm}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={$u$},
ylabel={$p$},
restrict x to domain=0:1.5,
ymin=-0.1, ymax=1.
xtick={0},
ytick={0.1,1}
]
({sqrt(35)*(1-x^(1/7))},
x);
({(x-0.1)/sqrt(7/400)/(1+sqrt(6/7*(10*x-1)))},
x);
\coordinate[circle,fill,inner sep=1pt, label=above right:{$U_1$}]
(U1) at (axis cs:0,1);
\coordinate[circle,fill,inner sep=1pt, label=below right:{$U_2$}]
(U2) at (axis cs:0,0.1);
\node[name intersections={of=RW and SW, by=Ua},circle,fill,inner sep=1pt]
at (Ua) {};
\end{axis}
\end{document}


Now I could also work without pgfplots, but since I am already using it for other graphs in the document, consistency would be tedious to achieve.

-
I did something similar here tex.stackexchange.com/questions/88386/… but it's not hack-free –  percusse Jun 11 '13 at 12:53

This is only a partial solution and maybe not the best solution... It is partial because the parameters for drawing the tick has to be changed for different plots and because there are only principal ticks (lower x-axis and left y-axis)

See also this question: Coordinates of intersections

\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\usepackage{pgfplots}

\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{2mm}
\usetikzlibrary{intersections,calc}

\makeatletter

\newcommand\transformxdimension[1]{
\pgfmathparse{((#1/\pgfplots@x@veclength)+
\pgfplots@data@scale@trafo@SHIFT@x)/10^\pgfplots@data@scale@trafo@EXPONENT@x}
}

\newcommand\transformydimension[1]{
\pgfmathparse{((#1/\pgfplots@y@veclength)+
\pgfplots@data@scale@trafo@SHIFT@y)/10^\pgfplots@data@scale@trafo@EXPONENT@y}
}

\makeatother

\begin{document}

\begin{tikzpicture}

\begin{axis}[
restrict x to domain=0:1.5,
ymin=-0.1, ymax=1.,
xmin=-0.1,xmax=1.6,
clip=false,
xtick={0},
ytick={0.1,1}]

({sqrt(35)*(1-x^(1/7))},x);
({(x-0.1)/sqrt(7/400)/(1+sqrt(6/7*(10*x-1)))},x);
\coordinate[circle,fill,inner sep=1pt, label=above right:{$U_1$}]
(U1) at (axis cs:0,1);
\coordinate[circle,fill,inner sep=1pt, label=below right:{$U_2$}]
(U2) at (axis cs:0,0.1);

\draw[name intersections={of=RW and SW, name=i}] (i-1) -- (i-1)
% this is only to have the coordinate of the intersection as last used coordinate

\pgfextra{\pgfgetlastxy{\macrox}{\macroy}%
\global\let\macrox\macrox%
\global\let\macroy\macroy};
%this save the x and y coordinate into \macrox and \macroy

\node[circle,fill,inner sep=1pt] at (\macrox,\macroy) {};
% draes the node at the intersection

\draw[] (\macrox,0) -- (\macrox,3) node[pos=-1.5]
{\transformxdimension{\macrox}
\pgfmathprintnumber{\pgfmathresult}};
\draw[] (0,\macroy) -- (3,\macroy) node[pos=-3.5]
{\transformydimension{\macroy}
\pgfmathprintnumber{\pgfmathresult}};
% draws the x tick and y tick of the intersection

\end{axis}

\end{tikzpicture}

\end{document}

-
There are a couple of typos in the code (missing \ before pgfplots@data@..., } instead of ] after pos=-1.5. Could you correct the code? –  Jake Jun 10 '13 at 16:06
Sorry, I made some mistake in copying the code, now it should work –  Red Jun 10 '13 at 18:31
Ok, this is nice, but the more I work with pgfplots, the more I feel like it is not suited for what I intend to do, because this problem was only the first step. I played around with what you gave me, but I always end up in a stalemate, since apparently, pgfplots does not compile line after line, but does the /path operations last, thus I am very limited. For instance, I cannot use \pgfgetlastxy to get some coordinates, then use them to set a new macro with \pgfmathsetmacro, because by then they are undefined. Thank you anyways, I learned a bunch. –  zuggg Jun 11 '13 at 6:48
My first idea was of drawing the two curves in an axis environment and then to add a second axis environment to draw the x and y ticks but unfortunately xtick={\transformxdimension{\macrox} \pgfmathprintnumber{\pgfmathresult}} gives me error... If there is a way of putting the \macrox and \macroy to xtick and ytick arguments it would much better –  Red Jun 11 '13 at 8:12
@zugg: If you edit your question to explain what you're aiming to achieve, maybe we can help. –  Jake Jun 11 '13 at 11:47