Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Ploting graph with gnuplot: manually determine x axis

  1. Oct 14, 2013 #1
    Hi there,

    It's the first time I am using gnuplot to plot a graph and I watched all sorts of tutorials and advices on google but I just can't find a good solution!

    Let me try to explain what the problem is... The experiment: I have a microphone and a speaker in closed box. The speaker is fixed in one corner but the microphone is movable on the x axis (along the edge of the box - inside, of course). I get a .dat file with three columns. The first column is frequency which is constant at 304 Hz, the second and third column are both voltage, second is voltage amplitude and third average voltage (one measure is 3 s long). I have to "walk" the entire box, so the x goes from 0 cm to 50 cm (steps by 1 cm). (all measurements are thereby discrete).

    Now how on earth can I convince gnuplot to plot me x axis with values from 0 to 50 and for y axis to call data from .dat file?

    I hope my english isn't too bad. Thanks for your help!
  2. jcsd
  3. Oct 15, 2013 #2
    OR any other program if nobody is familiar with gnuplot...
  4. Oct 22, 2013 #3


    User Avatar
    Science Advisor

    I would add the number of the observation as column 1 in your data file and then e.g.:
    plot "yourdata.dat" using 1:3, "yourdata.dat" using 1:4

    to plot the two voltages vs. observation number. I think there is also a way to count the lines. Usually,
    the manual is a good source for these kind of questions:-)
  5. Oct 23, 2013 #4


    User Avatar
    Science Advisor

    Even simpler: "0" seems to be the line number (look for "pseudocolumns" in the index). Hence you don't have to add the line number to your file:
    plot "yourdata.dat" using 0:2, "yourdata.dat" using 0:3
    or, even simpler
    plot "yourdata.dat" using 2, "yourdata.dat" using 3
  6. Oct 23, 2013 #5
    Well that is absolutely PERFECT! As easy as that. :)

    Thank you very much!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook