![]() |
| The plot generated by gnuplot |
Let's take a look at how this diagram was produced.
First, I used two data files, b02-phone-data.txt and b02-tablet-data.txt that both have the following structure:
# 1 3 5 7 9 11 m_from_AP avg_dB
-54 -50 -53 -48 -50 -50 4.36 -50.83333333
-59 -52 -54 -56 -59 -60 7.96 -56.66666667
-62 -54 -60 -58 -61 -60 13.26 -59.16666667
....
The first line is a comment (#). Data is separated by space, the first 6 columns give the measured dB values, col 7 gives the distance from the access point in meters and col 8 gives the average over the first 6 columns. Data in the file is sorted by distance from the access point. This is necessary for the plotting of the trend line because gnuplot plots all data as it is read line by line. Therefore, if the data jumps around the plot the trend line would end up a zigzagging chaos.
For plotting I used a plotfile called plot-measurements.plt:
# Plotfile for rooftop data
cd "C:/Users/tina/Desktop/Measurements"
# settings
set xrange [0:*]
set yrange [-100:0]
set xlabel "[m]"
set ylabel "[dBm]"
set title "Measurements Building 02"
set style circle radius 0.4
# Print to file
set terminal png truecolor size 640,480 xFFFFFF
set output "comparison-tablet-phone.png"
#
plot 'b02-tablet-data.txt' u 7:1 w circles lc rgb "orange" fs transparent solid 0.5 noborder title "Tablet", '' u 7:2 w circles lc rgb "orange" fs transparent solid 0.5 noborder notitle, '' u 7:3 w circles lc rgb "orange" fs transparent solid 0.5 noborder notitle, '' u 7:4 w circles lc rgb "orange" fs transparent solid 0.5 noborder notitle, '' u 7:5 w circles lc rgb "orange" fs transparent solid 0.5 noborder notitle, '' u 7:6 w circles lc rgb "orange" fs transparent solid 0.5 noborder notitle, '' u 7:8 w lines lc rgb "orange" notitle, 'b02-phone-data.txt' u 7:1 w circles lc rgb "blue" fs transparent solid 0.5 noborder title "Phone", '' u 7:2 w circles lc rgb "blue" fs transparent solid 0.5 noborder notitle, '' u 7:3 w circles lc rgb "blue" fs transparent solid 0.5 noborder notitle, '' u 7:4 w circles lc rgb "blue" fs transparent solid 0.5 noborder notitle, '' u 7:5 w circles lc rgb "blue" fs transparent solid 0.5 noborder notitle, '' u 7:6 w circles lc rgb "blue" fs transparent solid 0.5 noborder notitle, '' u 7:8 w lines lc rgb "blue" notitle
#
unset output
If you use the .plt extension you can use the File->Open dialog in the windows version of gnuplot more easily (.plt is the default extension used in that dialog) but it's just a normal text file that can be edited with any text editor.
The file first sets up the working directory and then some settings for the axises and title. Since we want to plot with circles instead of points, we also set up their size. Next come the settings for file output. Note that we must use the truecolor option for the png terminal; otherwise our circles will be opaque! The actual plot command works as follows:
plot 'b02-tablet-data.txt' u 7:1 w circles lc rgb "orange" fs transparent solid 0.5 noborder title "Tablet",Plot from the given file using col 7 as x coordinate and col 1 as y coordinate. With circles. Linecolor rgb "orange" (this can be any rgb name or an rgb number, eg. you could use rgb "#FF0000" instead of rgb "red"). Fill style transparent solid 0.5 - there's a solid fill (as opposed to a pattern) that's 50% transparent with no border. The legend title for this data is "Tablet".
The command continues with
'' u 7:2 w circles lc rgb "orange" fs transparent solid 0.5 noborder notitle,
where ' ' means "the same file as in the previous command". Here, we use col 2 as y coordinate, otherwise the command is the same. We don't want another legend entry, so we use notitle. This repeats for all columns until (and including) col 6.
The trend line is finally produced by
'' u 7:8 w lines lc rgb "orange" notitle,
which uses col 8 (the average) as the y coordinate. Instead of a circle, we now plot a line with the same color as the circles. Again, we don't want any additional legend entry.
And when all this is done for the tablet data, we do it all over again for the phone data - only this time we use the phone data file and the "blue" color.
And voilá, a scatterplot with semi-transparent data points. Too bad that gnuplot doesn't support any other symbol than a circle if you want to use transparency.
If you want to learn more about gnuplot plotting you might want to check out the links HERE.

Keine Kommentare:
Kommentar veröffentlichen