开发者

Multiple datasets in gnuplot: difference in behavior of index with iteration vs range

开发者 https://www.devze.com 2023-03-22 03:44 出处:网络
I think I understand from the behavior how these two 开发者_开发百科plot commands differ, but I don\'t really understand why they differ.That is, I didn\'t expect there to be a difference.The two case

I think I understand from the behavior how these two 开发者_开发百科plot commands differ, but I don't really understand why they differ. That is, I didn't expect there to be a difference. The two cases are:

plot for [i=0:3] 'ctg-y2.dat' index i using 2 title columnheader(2) with lines

and

plot 'ctg-y2.dat' index 0:3 using 2 title columnheader(2) with lines

(the example datafile is http://gnuplot.cvs.sourceforge.net/viewvc/gnuplot/gnuplot/demo/ctg-y2.dat)

The first one does what I would expect: for each of four datasets in the file, read a column header from the first line of the dataset, and plot the remaining data. The second one does something rather different: it does not read a column header for any dataset but the first, and it seems to plot all the data as if it were part of one dataset. The result is a mess, since the implicit x values don't match up correctly.

The description of index in the manual doesn't talk about this behavior of using a range with index, as near as I can tell. Is it documented somewhere? Is this a bug? Am I doing something stupid?


I have never used the index before, but if I understand it correctly, it seems to merge all indexed data sets to a single set. This is why the lines all appear in the red color. However, if plotted against the column index and not a given index (e.g. using 2 vs using 1:2) it seems to fall back to index 1. This is due to the fact that the first line cannot be interpreted (since it is a title).
The issue with the column headers seems to be working ok, since gnuplot expects to have just a single dataset, which is combined with the keyword index, and therefor does not expect to have multiple column headers.

Since you already solved your problem with the iterations there is no need for further suggestions. I think this is exactly how you should plot your data.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号