# Plot functions and their point of intersection

We are plotting three functions as follows

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[enlargelimits=false]

\addplot[domain=0:1,yellow] {0.5/( 2-x)^3 * 1.0 / sqrt(16 + 14 / (2-x)^4 ) };

(1/36)*(48*(2-x)^2+16*(2-x)^6-8*(2-x)^3*sqrt(280-792*x+966*x^2-640*x^3+240*x^4-48*x^5+4*x^6))/((2-x)
^2*(4*(2-x)^3+2*sqrt(280-792*x+966*x^2-640*x^3+240*x^4-48*x^5+4*x^6)))};
\end{axis}
\end{tikzpicture}

\end{document}


1. Y-axis has a marker 5 * 10 ^{-2}. We only want 0.05

2. Draw vertical lines from the intersection point between blue and yellow (also between blue and red curve) onto the axis and label the points on the axis.

3. Instead of lines we want to use symbols for at least two out of three plots.

4. What else can be done to make it more appealing.

-
Herbert Thank you. – Mia Dec 28 '12 at 11:53
Thank you Adorable Creature. Now we have a minimum working example. Help us make it better. – Mia Dec 28 '12 at 13:23
About the (3.): use mark= option for \addplot, for example: \addplot[domain=0:1,yellow,mark=*], where mark can be found in pgfplots manual in the section 4.6.1. Combining with only marks would get rid of smooth line. – m0nhawk Dec 28 '12 at 13:40
For (2.), tex.stackexchange.com/questions/38461/… (and the one I mentioned before, tex.stackexchange.com/questions/83503). – Torbjørn T. Dec 29 '12 at 10:17
For (1.) yticklabel style={/pgf/number format/fixed} – hpesoj626 Dec 31 '12 at 7:50

Here is an ugly hack for the answer the unanswered session. I've slightly modified Jake's axis coordinate transformation.

When the marks are introduced, finding intersections would be even more of a hack hence drawing the functions twice might be easier (one for the intersection without drawing, one for the marks). On a personal note, I've tried the only marker curves and intersection in between markers mean nothing visually. Hence you might reconsider that idea. Instead I've color coded the extra nodes to distinguish what is what.

The main difficulty is that the information required is spread out to different layers of TikZ, pgfplots plot, and pgfplots visualization environments. So if anyone else has a better fix I can delete this one.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usetikzlibrary{intersections,plotmarks}

\makeatletter
\def\markxof#1{
\pgf@process{#1}
\pgfmathparse{\pgf@x/\pgfplotsunitxlength +\pgfplots@data@scale@trafo@SHIFT@x)/10^\pgfplots@data@scale@trafo@EXPONENT@x}
}
\makeatother

\begin{document}

\begin{tikzpicture}

\begin{axis}[
enlargelimits=false,
yticklabel style={/pgf/number format/fixed},
domain=0:1,
]

\addplot[name path global=funone,blue] {(1-x)/5};
\addplot[name path global=funtwo,yellow] {0.5/( 2-x)^3 * 1.0 / sqrt(16 + 14 / (2-x)^4 ) };
\addplot[name path global=funthree,red] {
(1/36)*(48*(2-x)^2+16*(2-x)^6-8*(2-x)^3*sqrt(280-792*x+966*x^2-640*x^3+240*x^4-48*x^5+4*x^6))/((2-x)
^2*(4*(2-x)^3+2*sqrt(280-792*x+966*x^2-640*x^3+240*x^4-48*x^5+4*x^6)))};

\path[name intersections={of={funone and funtwo},name=i},
name intersections={of={funone and funthree},name=in}] (i-1) (in-1);
\pgfplotsextra{
\path (i-1)  \pgfextra{\markxof{i-1}\xdef\myfirsttick{\pgfmathresult}}
(in-1) \pgfextra{\markxof{in-1}\xdef\mysecondtick{\pgfmathresult}};
}

\end{axis}

\draw[ultra thin, draw=gray] (i-1 |- {rel axis cs:0,0}) node[fill=yellow,yshift=-5ex]
{\pgfmathprintnumber[fixed,precision=5]\myfirsttick} -- (i-1);
\draw[ultra thin, draw=gray] (in-1 |- {rel axis cs:0,0}) node[fill=red,yshift=-7.5ex]
{\pgfmathprintnumber[fixed,precision=5]\mysecondtick} -- (in-1);

\end{tikzpicture}

\end{document}


-
I know, the single closing parenthesis in \pgfplots@data@scale@trafo@SHIFT@x) is not a typo, but why do we need this unbalanced delimiter? – Henri Menke Dec 17 '14 at 20:28
@HenriMenke Because I'm both sloppy and lucky. There must be an opening brace too but here since up to that point there is nothing fancy going on pgfmath closes the current scope and forgives it due to the closing delimiter. It's just how pgfmath decides about the precedence rules and does not keep track of delimiter groups (they are not TeX scopes). – percusse Dec 17 '14 at 20:48