[Tex/LaTex] Plot functions and their point of intersection

intersectionsplottikz-pgf

We are plotting three functions as follows

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

\addplot[domain=0:1,blue] {(1-x)/5};

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

\addplot[domain=0:1,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)))};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Please help us in obtaining

  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.

Best Answer

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}

enter image description here

Related Question