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

Thread: gnuplot

  1. #1
    Join Date
    Nov 2012
    Beans
    14

    gnuplot

    I'm having trouble creating a plot from a data file ( table.data ) using table.gnu.
    I am using the bash prompt,
    p2t16@linux07:~/Lab05/lookup$ gnuplot < table.gnu
    I have attached the files within a zip file.

    I was a bit worried that this post doesn't convey my appreciation for your help and I thought of a reply to my own post that I found amusing, it goes as follows,

    "That post has so little emotion it seems as though the worldwide LHC computing grid has gained sentience and is trying to understand itself".

    Iain Taylor
    Attached Files Attached Files
    Last edited by iain150; November 21st, 2012 at 12:21 AM.

  2. #2
    Join Date
    Nov 2012
    Beans
    14

    Re: Help with gnuplot.

    Also the male file contains the lines:


    CC=gcc
    libs=-lm
    objs=lookup.o main.o

    lookup.o: lookup.c
    $(CC) -c $^ -o $@

    main.o: main.c
    $(CC) -c $^ -o $@

    main: $(objs)
    $(CC) $^ -o $@ $(libs)

    .PHONY: clear
    clear:
    rm -f *.o




    my question is what does "-lm" stand for i cannot find it on google.

  3. #3
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: Help with gnuplot.

    Deleted

    Nevermind. I don't know what I'm talking about. I found that entering in the commands one line at a time into GNU plot just as you have them seems to work fine. I'm not sure why it's not reading from the table.gnu file correctly. Better let an expert answer this one!
    Last edited by drmrgd; November 20th, 2012 at 08:05 PM. Reason: Bad Advice!

  4. #4
    Join Date
    Apr 2012
    Beans
    7,256

    Re: gnuplot

    Hmm well your zip file worked for me - with the one exception that I renamed the files from

    Code:
    table (copy).data table (copy).gnu
    to

    Code:
    table.data table.gnu
    I just unzipped it in a new dir, then cd'ed there and started interactive gnuplot, then loaded the .gnu file

    Code:
    ~/Documents/forums/iain150$ gnuplot
    
        G N U P L O T
        Version 4.4 patchlevel 3
        last modified March 2011
        System: Linux 3.2.0-33-generic-pae
    
        Copyright (C) 1986-1993, 1998, 2004, 2007-2010
        Thomas Williams, Colin Kelley and many others
    
        gnuplot home:     http://www.gnuplot.info
        faq, bugs, etc:   type "help seeking-assistance"
        immediate help:   type "help"
        plot window:      hit 'h'
    
    Terminal type set to 'wxt'
    gnuplot> 
    gnuplot> load "table.gnu"
    gnuplot>
    I got a nice plot of 'Kinetic energy' versus 'Velocity'

    Like drmgd above I don't understand what your makefile has to do with gnuplot
    Last edited by steeldriver; November 20th, 2012 at 08:12 PM.

  5. #5
    Join Date
    Apr 2011
    Location
    Maryland
    Beans
    1,461
    Distro
    Kubuntu 12.04 Precise Pangolin

    Re: gnuplot

    Ahhhh...I think that's the difference; you started an interactive session and then loaded the file. I was trying to load it from the commandline just as the OP did and couldn't get a plot generated. Seems to work just fine if you follow Steeldriver's method. I need to learn Gnuplot. Seems very useful (I've been working with R these days).

  6. #6
    Join Date
    Nov 2012
    Beans
    14

    Re: gnuplot

    yes the commands work fine but I should be able to get 2 graphs,
    one of velocity and kinetic energy and one of velocity and relative mass when I run the bash line

    gnuplot < table.gnu,

    which it does not do, it makes the file but there is no data,
    ie no graph.

    I'm still new to c and this is my first attempt at a gnuplot so I don't know why my file ( table.gnu ) isn't working even if the commands work when entered manually on the command line.

  7. #7
    Join Date
    Nov 2012
    Beans
    14

    Re: gnuplot

    The makefile is nothing to do with gnuplot it is a seperate piece of code that I don't know what it does.

  8. #8
    Join Date
    Nov 2012
    Beans
    14

    Re: gnuplot

    Thanks for the feedback so far.

  9. #9
    Join Date
    Apr 2012
    Beans
    7,256

    Re: gnuplot

    Ah I see - well I'm not much of a gnuplot expert but you probably need to tell it where to plot the 2 graphs - else by default it probably overwrites the first one with the second one

    e.g. add a new term command before the second plot

    Code:
    set autoscale
    unset logscale; set logscale y
    
    set output 'Reletivistic-mass.png'
    set xlabel "Velocity (m/s)"
    set ylabel "Relitivistic mass (Kg)"
    plot "table.data" using 1:2 title "Relitivistic Mass" w line
    
    set term wxt 1
    
    set output 'Kinetic-energy.png'
    set xlabel "Velocity (m/s)"
    set ylabel "Kinetic energy (J)"
    plot "table.data" using 1:3 title "Kinetic Energy" w line
    You may want to replace 'wxt' with the default display terminal type for your environment

  10. #10
    Join Date
    Apr 2012
    Beans
    7,256

    Re: gnuplot

    Oh and regarding your makefile question '-lm' is a directive telling the linker that your executable needs symbols from the standard math library 'libm'

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
  •