plot w/ histogram overlay

  • Abe Stephens

    Abe Stephens - 2007-02-20


    I'd like to plot a function and then place a histogram with counts based on the function in the same figure. The problem is that I can't seem to avoid gnuplot using the same number of samples to evaluate the function and the histogram bins.

    I am attempting to make an illustrative example. Essentially I'd like to show an approximation of the analytic function's integral.

    For example if I plot:

    f(x) = (1/((x+.3)*(x+.3)) + 1)-(sin(x*5)+cos(x*10))*0.1
    plot [0:2] [] f(x) notitle lw 5, f(x)*1.5 with boxes

    Of course I get an enormous number of histogram bins, when I'd really like to see a small handful (3-6). I realize that I'm trying to use gnuplot to produce a synthetic example when most people are probably making histograms using measured data, but I'd appreciate any advice.


    • Hans-Bernhard Broeker

      Your problem begins earlier than you think.  Function plots don't get binned into histograms by gnuplot.  If you want to plot a histogram, you'll have to save the plotted data to a file (--> help table), then bin (--> help smooth frequency) and plot that.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks