Ploting graph with gnuplot: manually determine x axis

In summary, you need to create a .dat file with columns for frequency (kHz), voltage (V), and average voltage (V/3s). You need to "walk" the entire box, so the x goes from 0 cm to 50 cm (steps by 1 cm). To plot the data, you can use gnuplot with 1:3 or 1:4.
  • #1
skrat
748
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
  • #2
OR any other program if nobody is familiar with gnuplot...
 
  • #3
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:-)
 
  • #4
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
 
  • #5
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!
 

FAQ: Ploting graph with gnuplot: manually determine x axis

How do I manually determine the x-axis in Gnuplot?

To manually determine the x-axis in Gnuplot, you can use the "set xrange" command followed by the minimum and maximum values for the x-axis. For example:

set xrange [0:10]

This will set the x-axis to range from 0 to 10. You can also use the "set xtics" command to manually set the tick marks on the x-axis.

Can I change the scale of the x-axis in Gnuplot?

Yes, you can change the scale of the x-axis in Gnuplot by using the "set logscale x" command. This will create a logarithmic scale for the x-axis. You can also use the "set logscale xy" command to create a logarithmic scale for both the x and y axes.

How do I add labels to the x-axis in Gnuplot?

To add labels to the x-axis in Gnuplot, you can use the "set xlabel" command followed by the desired label in quotes. For example:

set xlabel "Time (s)"

This will add the label "Time (s)" to the x-axis. You can also use the "set xtics" command to add custom tick marks and labels to the x-axis.

How do I change the font size of the x-axis labels in Gnuplot?

To change the font size of the x-axis labels in Gnuplot, you can use the "set xlabel font" command followed by the desired font size. For example:

set xlabel font "Helvetica, 14"

This will change the font of the x-axis label to Helvetica with a font size of 14. You can also use the "set xtics font" command to change the font size of the tick labels on the x-axis.

Can I add a title to my Gnuplot graph?

Yes, you can add a title to your Gnuplot graph by using the "set title" command followed by the desired title in quotes. For example:

set title "Temperature vs. Time"

This will add the title "Temperature vs. Time" to your graph. You can also use the "set title font" command to change the font and size of the title.

Similar threads

Replies
1
Views
2K
Replies
2
Views
2K
Replies
2
Views
945
Replies
1
Views
4K
Replies
2
Views
1K
Replies
7
Views
1K
Back
Top