|
From: Martin P. <ma...@po...> - 2017-11-02 11:20:17
Attachments:
boxplot.g.txt
data.dat.txt
|
Hello, I am trying to plot multiple sets of data with the boxplot style. All sets of data have their unique X axis value. In my small example, I have got it to work for X = 50, X = 55 and X = 60 in the same plot. However, I am not quite satisfied with the solution. >From boxplot.g.txt, this is the part where the X values are determined: index i using (50 + (i * 5)):1 As you can see, the X value is calculated based on the index of the set in the data file. However, I would like to use the set's numeric header instead. I have tried to replace (50 + (i*5)) by (columnheader(i + 1)), but Gnuplot complains about "undefined function: columnheader." The columnheader(i + 1) call works perfectly fine just a few characters away in the same plot line, when it is used for setting the title. How can I use the header of the data set as the X axis value? Best regards, Martin Pola |
|
From: theozh <th...@gm...> - 2017-11-03 00:51:37
|
Hi Martin,
if you exchange your line:
plot for [i=0:(STATS_blocks - 1)] 'data.dat' index i using (50 + (i * 5)):1 title columnheader(i + 1)
by these lines:
array XValue[3]
plot for [i=1:3] 'data.dat' u 1:(XValue[i]=$1,1) every 1:1::(i-1)::(i-1) w p ls 1 not
plot for [i=1:3] 'data.dat' u (XValue[i]):1 every 1:1:1:(i-1)::(i-1) title sprintf("%g",XValue[i])
and if you change your data such there is only one empty line instead of two, you should get your desired result.
What it basically does is
- creating an array of XValues
- the first plot just extracts the first numbers of each datablock and writes them into the array
- the second plot command finally plots at the XValues from this array.
However, seems to work but not very elegant... maybe there is a smarter way...
Limitation:
in the for loop you can't use [i=1:STATS_block] for a variable number of blocks, because apparently STATS_blocks needs two empty data lines two count datablocks, whereas "every" only allows for one empty line.
See also my other question/post about datablock separation, which hopefully somebody can comment on.
Theo.
|
|
From: theozh <th...@gm...> - 2017-11-03 22:22:40
|
hi again, it should work without changing your data with these lines: array XValue[3] plot for [i=0:STATS_blocks-1] 'data.dat' index i using (XValue[i+1]=$1,1):1 every 1:1:0:0:0:0 notitle plot for [i=0:STATS_blocks-1] 'data.dat' index i using (XValue[i+1]):1 title columnheader(i + 1) |
|
From: Martin P. <ma...@po...> - 2017-11-10 15:24:13
|
Thank you for your two suggestions! I have tried them both, and although I don't get any error message, the plots are empty. The plot in the first suggestion maintain the desired X range from 0 to 60, while the plot in the second example has a range from -0.5 to 2.5. The data has only been modified in the first suggestion; I replaced three line breaks by two line breaks, causing only a single empty line between data sets. Attached are the samples I tried with. Do our .g files differ? I run Version 5.2 patchlevel 0 last modified 2017-09-01 for the record. - Martin On fredag 3 november 2017 kl. 23:22:25 CET you wrote: > hi again, > it should work without changing your data with these lines: > > array XValue[3] > plot for [i=0:STATS_blocks-1] 'data.dat' index i using (XValue[i+1]=$1,1):1 > every 1:1:0:0:0:0 notitle plot for [i=0:STATS_blocks-1] 'data.dat' index i > using (XValue[i+1]):1 title columnheader(i + 1) |
|
From: theozh <th...@gm...> - 2017-11-10 19:54:46
Attachments:
boxplot2.plt
|
sorry, I tested it in a wxt terminal. Obviously, it is different with png (btw I would use pngcairo terminal). Something with "set output". Apparently, you have to set it twice (once again between the dummy plot and the second plot command). Furthermore, you need to close your output with "set output" at the end. The following should now really be working as all-in-one copy&paste code. |
|
From: Martin P. <ma...@po...> - 2017-11-13 08:55:33
|
Ah, that worked. Thanks a lot! I'll keep in mind to use pngcairo rather than png in the future. - Martin On Friday, November 10, 2017 8:54:41 PM CET theozh wrote: > sorry, I tested it in a wxt terminal. > > Obviously, it is different with png (btw I would use pngcairo terminal). > > Something with "set output". > Apparently, you have to set it twice (once again between the dummy plot and > the second plot command). Furthermore, you need to close your output with > "set output" at the end. > > The following should now really be working as all-in-one copy&paste code. |