Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to plot a stepped gauss curve as shown below. Yet I want to do this dynamically (in text) so I can alter it later.

http://media.texample.net/tikz/examples/PDF/gnuplot-tikz-terminal.pdf

I know how to plot a smooth gauss but I really need the stepped one. Also a bar (option ybar) won't do because I only need the contour of the bar plot (no bars, just one curve).

I've tried:

\draw[black,thick] plot[id=gg,raw gnuplot] function{
    set xrange [0:7.5];
    set samples 30;
    normal(x,mu,sigma)=sigma<=0?1/0:invsqrt2pi/sigma*exp(-0.5*((x-mu)/sigma)**2);
    invsqrt2pi = 0.398942280401433;
    plot 3.5*normal(x,1.5,0.5) with histeps;
};

yet the histeps option from gnu plot doesn't kick in... (this script does work when in gnuplot).

share|improve this question

1 Answer 1

up vote 8 down vote accepted

When you use gnuplot in TikZ, all that happens is that you get gnuplot to generate a series of points in a table that is read and rendered using TikZ. The histeps option doesn't change the data, but only the rendering (in gnuplot), so it doesn't influence what you see in TikZ. Instead, you can use the TikZ option const plot:

\draw[black,thick] plot[id=gg,raw gnuplot, const plot] function{
    set xrange [0:7.5];
    set samples 30;
    normal(x,mu,sigma)=sigma<=0?1/0:invsqrt2pi/sigma*exp(-0.5*((x-mu)/sigma)**2);
    invsqrt2pi = 0.398942280401433;
    plot 3.5*normal(x,1.5,0.5);
};
share|improve this answer
    
+1, you made my day! –  romeovs Nov 13 '11 at 12:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.