1

I am not an expert in drawing graphs using LaTeX. I am trying to draw graphs by xfig and DIA but it seems that graphing in LaTeX is more gorgeous (correct me if I am wrong).

I am trying to re-draw this picture.

enter image description here

I have tried by DIA which looks like

enter image description here

I am really not satisfied :-(. So If you can re-draw the picture identical with LaTeX equations appeared on the figure then I will be able to follow you that how you have done. And a request, please provide me some most useful tips about drawing in LaTeX.

If I am able to draw a graph in dia then will i be able to export the graph data as LaTeX so that should be added to my LaTeX file?

Sorry for all the question.

2
  • 3
    You got a pretty detailed response to your last question on plotting. Maybe you could start adapting that, and if you run into problems, ask a more concrete question here (at the moment, this is a "draw this for me question")
    – Jake
    Nov 11, 2013 at 12:50
  • If you have any function to describe those curves it's so much more easy.
    – osjerick
    Nov 11, 2013 at 13:24

1 Answer 1

6

Gaussian plot:

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
    \pgfplotsset{compat=1.9}
    \pgfmathdeclarefunction{gauss}{2}{%
        \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
    }

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[unit vector ratio=1 1,
                smooth,
                xmin=-2,xmax=2,
                ymin=0,ymax=1.2,
                axis x line=bottom,
                axis y line=center,
                xlabel=$x$,
                xlabel style={at={(1,0)}, anchor=west},
                ylabel=$\varepsilon(x)$,
                ylabel style={anchor=south},
                xtick=\empty,
                extra x ticks={0.5},
                extra x tick labels={$x_0$},
                ytick=\empty
            ]
            \addplot[thick,red,samples=100] {gauss(0.5,0.5)};
            \draw[latex-] (axis cs:0,0.475) -- (axis cs:0.35,0.475);
            \node at (axis cs:0.5,0.475) {$\frac{1}{m}$};
            \draw[-latex] (axis cs:0.65,0.475) -- (axis cs:1,0.475);
        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

And the error function (thanks for the function from here):

\documentclass[tikz]{standalone}

\usepackage{pgfplots}
    \pgfplotsset{compat=1.9}
\makeatletter
    \pgfmathdeclarefunction{erf}{1}{%
        \begingroup
            \pgfmathparse{#1 > 0 ? 1 : -1}%
            \edef\sign{\pgfmathresult}%
            \pgfmathparse{abs(#1)}%
            \edef\x{\pgfmathresult}%
            \pgfmathparse{1/(1+0.3275911*\x)}%
            \edef\t{\pgfmathresult}%
            \pgfmathparse{%
                1 - (((((1.061405429*\t -1.453152027)*\t) + 1.421413741)*\t 
                -0.284496736)*\t + 0.254829592)*\t*exp(-(\x*\x))}%
            \edef\y{\pgfmathresult}%
            \pgfmathparse{(\sign)*\y}%
            \pgfmath@smuggleone\pgfmathresult%
        \endgroup
    }
\makeatother

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[unit vector ratio=1 1,
                smooth,
                xmin=-2,xmax=3,
                ymin=-1.2,ymax=1.2,
                axis x line=center,
                axis y line=center,
                xlabel=$x$,
                xlabel style={at={(1,0.5)}, anchor=west},
                ylabel=$\phi(x)$,
                ylabel style={anchor=south},
                xtick=\empty,
                extra x ticks={0.5},
                extra x tick labels={$x_0$},
                ytick=\empty,
                extra y ticks={-1, 1},
                extra y tick labels={$-\frac{m}{\sqrt{\lambda}}$, $\frac{m}{\sqrt{\lambda}}$},
                extra y tick style={tick label style={anchor=west}}
            ]
            \addplot[thick,red,samples=100] {erf(x - 0.5)};
        \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .