2

I am trying to draw the Rogers Diffusion of Innovations Curve in Tikz figures Latex. I am a beginner in Tikz and not sure where to start. It is the curve on the right and shown here.enter image description here

2

Here's an alternative approach using luamplib to include some Metapost code. Compile with lualatex.

enter image description here

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\usepackage{fontspec}\setmainfont{TeX Gyre Heros}
\begin{document}
\mplibtextextlabel{enable}
\mplibnumbersystem{double}
\begin{mplibcode}
beginfig(1);

    vardef exp(expr x) = mexp(256x) enddef; % hide MP's version of exp

    vardef normal_cdf(expr x) = 
        numeric sum, value;
        sum = value = x;
        for i=1 upto infinity:
           value := value * x * x / (2i+1);
           exitif abs(value)<eps;
           sum := sum + value;
        endfor
        1/2+(sum/2.50662827463)*exp(-1/2x*x)
    enddef;

    vardef normal_pdf(expr x) = 
        exp(-1/2x*x)/2.50662827463  % \sqrt(2\pi) \simeq 2.50663 
    enddef;

    path cdf_curve, pdf_curve;

    % horizontal and vertical units
    numeric u,v;
    u = 16mm; v = 16mm;

    numeric s, r; r=3; s=1/64;
    cdf_curve = ((-r,normal_cdf(-r)) for t=s-r step s until r: -- (t,normal_cdf(t)) endfor) xscaled u yscaled 4v;
    pdf_curve = ((-r,normal_pdf(-r)) for t=s-r step s until r: -- (t,normal_pdf(t)) endfor) xscaled u yscaled 5v;

    path xx;
    xx = (left--right) scaled (r*u);

    z1 = cdf_curve intersectionpoint (xx shifted (0,4v * 0.025)); % 2.5%
    z2 = cdf_curve intersectionpoint (xx shifted (0,4v * 0.160)); % 16%

    drawoptions(withpen pencircle scaled 1/4 withcolor 1/2 white);

    draw ( x1,-2) -- ( x1,4v) cutafter pdf_curve;
    draw ( x2,-2) -- ( x2,4v) cutafter pdf_curve;
    draw (  0,-2) -- (  0,4v) cutafter pdf_curve; % cheating
    draw (-x2,-2) -- (-x2,4v) cutafter pdf_curve; % because centred on 0

    % x-axis
    draw xx shifted 2 down;

    % y-scale
    draw (origin -- up scaled 4v) shifted (3u+4,0);
    for y=0 step 25 until 100:
       draw (3u+4,y/100*4v) -- (3u+6,y/100*4v);
       label.rt(decimal y,     (3u+6,y/100*4v));
    endfor

    drawoptions();

    draw cdf_curve withcolor red + 1/2green;
    draw pdf_curve withcolor 2/3 blue;

endfig;
\end{mplibcode}
\end{document}

Notes

  • I've assumed the curves are supposed to be the normal PDF and CDF but the OP does not really make this explicit.

  • You have to cheat to get the curves to meet in the middle like that. Notice that I've exaggerated the vertical scale of the PDF by 25%.

  • I've used the double-precision number system to avoid some turbulence in calculating the PDF for values outside the band -3 < x < 3.

  • If you want flatter ends to the curves, set r to a larger value (but the PDF is essentially zero outside the range -4 < r < 4).

  • The constant 2.50662827463 is \sqrt{2\pi}.

  • The remaining labels are left as an exercise for the reader.

5

This should give you a starting point.

\documentclass{article} 
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    enlargelimits=false,
    axis x line=bottom,
    axis y line=right,
    axis line style={-},
    tickwidth=0pt,
    domain=-3:3,
    xtick={-3,-2,-1,0,1},
    xticklabels={
      Innovators 2.5\%,
      Early Adopters 13.5\%,
      Early Najority 34\%,
      Late Najority 34\%,
      Laggards 16\%,
    },
    x tick label style={rotate=45,anchor=east},
    ylabel={Market share \%},
    ytick={0,25,50,75,100},
    ymin=0, ymax=110,
    samples=51, smooth, no markers,
    ]

    \addplot+[blue,very thick] {50*exp(-.5*x^2)};

    \addplot+[orange,very thick] {100 / (1 + exp(-2*x))};

    \pgfplotsinvokeforeach{-3,...,1} {
      \draw[help lines] (axis cs:#1,{50*exp(-.5*(#1)^2)}) -- (axis cs:#1,0);
    }

  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2

This will draw the Logistics function with the parameter k, as well as the first two labels. For a complete answer, the equation of the blue curve and the position of the vertical lines would be necessary.

\tiny
    \begin{tikzpicture}
        \def\k{5}
        \draw[yellow] [domain=0:1, scale=10] plot (\x,{1/(1+exp(-\k*(2*\x-1))});
        \draw node[anchor=north west, text width=2cm] {Innovators \\ 2.5\%} (0,0) -- node[anchor=north west, text width=2cm] {Early Adopters \\ 13.5\%}(2.7,0) -- (10,0) node[anchor=west] {0} -- (10,2.5)  node[anchor=west] {25} -- (10,5)  node[anchor=west] {50} -- (10,7.5)  node[anchor=west] {75} -- (10,10) node[anchor=west] {100};
        \node[rotate=-90, anchor = south, yshift=.75cm] at (10,5) {Market Share \%};
    \end{tikzpicture}
  • It's not really clear from the OP but I think the curve that looks like the logit is really supposed to the the normal CDF... – Thruston Dec 22 '16 at 14:16

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.