Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: histograms in gnuplot

  1. #1
    Join Date
    Jun 2010
    Location
    Manchester
    Beans
    93
    Distro
    Lubuntu 16.04 Xenial Xerus

    histograms in gnuplot

    hi

    Ive searched countless of gnuplot examples of histograms but all assume too much (for me at least). I'm looking for a gnuplot script that will generate something similar to:

    http://www.gcsemathstutor.com/histograms.php

    a nice simple GCSE data plot with variable bin widths. I've been following: http://gnuplot.sourceforge.net/demo/histograms.html but this doesn't show any 'data.file' and without this the example is useless really. I am familiar with gnuplot for functions in 2D, but the histogram defeats me.

    Can anyone offer a script that explains the datafile, gnuplot script and an output to a png or a jpeg file?


  2. #2
    Join Date
    Sep 2007
    Location
    TX, USA
    Beans
    385
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    did you look here?
    This should be a sticky, or a bug 'cos it ain't a feature

  3. #3
    Join Date
    Jun 2010
    Location
    Manchester
    Beans
    93
    Distro
    Lubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    Quote Originally Posted by PC_load_letter View Post
    did you look here?
    Ive seen that, it doesn't explain the data set; or anything for that matter!...

  4. #4
    Join Date
    Sep 2007
    Location
    TX, USA
    Beans
    385
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    Here it is:
    http://212.182.0.171/cgi-bin/dwww/us...mmigration.dat

    You can find the file on your hdd at the same location if you have the package gnuplot-doc installed.

    Hope this helps.
    This should be a sticky, or a bug 'cos it ain't a feature

  5. #5
    Join Date
    Sep 2007
    Location
    TX, USA
    Beans
    385
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    Also, in the gnuplot code, replace the immigration.dat by the path to the file.
    In my case I copied the file to the home folder and my last line in one of the examples was:
    Code:
    plot '~/immigration.dat' using 6:xtic(1) ti col, '' u 12 ti col, '' u 13 ti col, '' u 14 ti col
    and it worked!
    This should be a sticky, or a bug 'cos it ain't a feature

  6. #6
    Join Date
    Jun 2010
    Location
    Manchester
    Beans
    93
    Distro
    Lubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    Quote Originally Posted by PC_load_letter View Post
    Also, in the gnuplot code, replace the immigration.dat by the path to the file.
    In my case I copied the file to the home folder and my last line in one of the examples was:
    Code:
    plot '~/immigration.dat' using 6:xtic(1) ti col, '' u 12 ti col, '' u 13 ti col, '' u 14 ti col
    and it worked!
    Edit

    That was a big help, thanks. But I'm trying to get something similar to: http://www.gcsemathstutor.com/histograms.php

    I have (ignore the titles for now):

    Code:
    # If we don't use columnhead, the first line of the datafile
    # will confuse gnuplot, which will leave gaps in the plot.
    set key top left outside horizontal autotitle columnhead
    
    #set xtics rotate by 90 offset 0,-5 out nomirror
    set ytics out nomirror
    set ylabel 'frequency density'
    set title 'House Prices in Manchester £000s'
    
    set style fill solid border -1
    # Make the histogram boxes half the width of their slots.
    set boxwidth 3
    
    # Select histogram mode.
    set style data histograms
    # Select a row-stacked histogram.
    set style histogram clustered
    
    plot "~/Desktop/data" using 2:xticlabels(1) lc rgb 'green'
    with data

    Code:
    Date          Level_0_Mins  Level_1_Mins  Level_2_Mins
    2011-01-08    0.2         161.08        22.58
    2011-01-15    0.4         104.00        70.33
    2011-01-22    0.6         79.75         16.17
    2011-01-29    0.3         99.25         21.74
    2011-02-05    0.1         155.33        33.33
    What im really trying to emulate is:

    I'll try to attach a screenshot, one moment.
    Last edited by 1cookie; August 16th, 2011 at 07:16 PM.

  7. #7
    Join Date
    Jun 2010
    Location
    Manchester
    Beans
    93
    Distro
    Lubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    Screen shot attached. You see, I dont need all the bells and whistles, just a straight forward plot, with joined-up bin values. Thanks.
    Attached Images Attached Images

  8. #8
    Join Date
    Sep 2007
    Location
    TX, USA
    Beans
    385
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    This is what I'm getting with your code, could you list the changes that you want to make? Here:
    Attached Images Attached Images
    This should be a sticky, or a bug 'cos it ain't a feature

  9. #9
    Join Date
    Jun 2010
    Location
    Manchester
    Beans
    93
    Distro
    Lubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    Quote Originally Posted by PC_load_letter View Post
    This is what I'm getting with your code, could you list the changes that you want to make? Here:

    Hi
    I need a histogram which:

    The histogram shows the price distribution of houses in an area
    of Manchester. Prices are given in thousands of pounds (to the nearest thousand).

    see screenshot attached: (data included)

    Attached Images Attached Images

  10. #10
    Join Date
    Sep 2007
    Location
    TX, USA
    Beans
    385
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: histograms in gnuplot

    Quote Originally Posted by 1cookie View Post
    Hi
    I need a histogram which:

    The histogram shows the price distribution of houses in an area
    of Manchester. Prices are given in thousands of pounds (to the nearest thousand).

    see screenshot attached: (data included)

    I can probably take a closer look and see how to tweak your code to fit your needs, but in all honesty, gnuplot would not be my 1st choice for this task from the start. You can EASILY do this in LibreOffice Calc, Gnumeric, R (but it's not as easy as Calc), or even Python's Matplotlib.
    This should be a sticky, or a bug 'cos it ain't a feature

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •