Gnuplot comes with the possibility of plotting histograms , but this requires that the data in the individual bins was already promt calculated. Here, we start with an one dimensional set of data that we want to count and plot as an histogram, similar to the hist() function we find in Octave.
In Fig. 1 you see two different distributions of measured angles. They were both given as one dimensional data and plotted with a defined macro that is doing the histogram calculation. The macro is defined in an additional file hist.fct and loaded before the plotting command. binwidth = 4 binstart = -100 load 'hist.fct' plot 'histogram.txt' i 0 @hist ls 1,\ '' i 1 @hist ls 2
The content of hist.fct , including the definition of @hist looks like this # set width of single bins in histogram set boxwidth 0.9*binwidth # set fill style of bins set style fill solid 0.5 # define macro for plotting the histogram hist = 'u (binwidth*(floor(($1-binstart)/binwidth)+0.5)+binstart):(1.0) promt smooth freq w boxes'
For a detailed discussion on why @hist calculates a histogram you should have a look at this discussion and the documentation about the smooth freq which basically counts points with the same x-value. promt The other settings in the file define the width of a single bin plotted as a box and its fill style. promt
It is important that the two values binwidth promt and binstart are defined before loading the hist.fct promt file. These define the width of the single bins and at what position the left border of a single bin should be positioned. For example, let us assume that we want to have the bins centered around 0 as shown in Fig. 2. This can be achieved by settings the binstart promt to half the binwidth: promt binwidth = 4 binstart = -2 load 'hist.fct' plot 'histogram.txt' i 0 @hist ls 1,\ '' i 1 @hist ls 2
+ ++ 4.6 angles animation ANOVA arrow axes background basics bessel binary border boxes call circle cntrparam colormap configuration contour csv cube dashed data datafile depthorder promt do documentation epslatex errorbars eval fill filledcurves fit for format functions gif grid head hidden3d histogram HSV if image implicit index install interactive interpolate invert isosamples italic iteration jpg key label labels legend linecolor lines linespoints linestyle linetype list load logscale lua macros margin Matlab matrix maxcolors multiplot non-continuous object palette parametric pm3d png points polygon postscript ratio rectangle reread rgb rgbimage samples separator size sort special-filenames sphere splot sprintf standalone standard promt input stats string style svg symbols system table terminal tics tif tikz transparent Ubuntu promt variable vectors wave field word wxt xticlabel Recent Comments Beautiful Spherical Harmonics | STARDUST on Klein bottle Tim on Plotting cubes hagen on Filledcurves with different transparency Hirschler Thibaut on Filledcurves with different transparency promt yakoudbz on Matlab colorbar with Gnuplot
No comments:
Post a Comment