Ploting graph with gnuplot: manually determine x axis

Click For Summary

Discussion Overview

The discussion revolves around using gnuplot to plot data from an experiment involving a microphone and a speaker in a closed box. Participants explore how to set the x-axis values manually from 0 to 50 cm while utilizing data from a .dat file containing frequency and voltage measurements.

Discussion Character

  • Technical explanation
  • Exploratory
  • Homework-related

Main Points Raised

  • One participant describes their experimental setup and seeks guidance on plotting data in gnuplot.
  • Another participant suggests adding an observation number as the first column in the data file to facilitate plotting.
  • A different participant proposes using gnuplot's "pseudocolumns" feature to reference line numbers directly, eliminating the need to modify the data file.
  • Some participants express satisfaction with the simplicity of using the "0" pseudocolumn for plotting without additional data modifications.

Areas of Agreement / Disagreement

Participants generally agree on the utility of using gnuplot's features to plot the data, but there are multiple approaches suggested for achieving the desired outcome, indicating a lack of consensus on the single best method.

Contextual Notes

Some participants mention the potential for confusion regarding the use of line numbers and pseudocolumns, which may depend on the specific version of gnuplot or the data file format.

skrat
Messages
740
Reaction score
8
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!
 
Physics news on Phys.org
OR any other program if nobody is familiar with gnuplot...
 
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:-)
 
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
 
DrDu said:
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

Well that is absolutely PERFECT! As easy as that. :)

Thank you very much!
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
17K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
1
Views
10K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K