2

It might be very simple, but I cannot find the specific answer to this: how can I plot the first vs the last and the second to last columns in several files whose column number is variable? is there something like

plot "mydata.txt" using 1:-1? 

I've already tried to use tail, but I don´t know hot to specifically use it, and couldn´t make this answer Count columns in csv in gnuplot work neither :(

Thanks!

Community
  • 1
  • 1
madoro
  • 55
  • 7
  • 1
    See e.g. http://stackoverflow.com/a/32826047/2604213 – Christoph Sep 29 '15 at 14:48
  • Unfortunately I could not make this work, is there really not a reverse counting in gnuplot? – madoro Oct 01 '15 at 08:57
  • No, there isn't. That's why I gave you this link. Why couldn't you make this work? On which OS are you working? Do you have any strings in your columns? etc. – Christoph Oct 01 '15 at 09:44
  • Strings are commented, my data look like: `#Time 11:36:56 11:37:56 11:38:56 11:39:56 11:40:56 11:41:56 11:42:56 PROMEDIO DESV_EST \n 11.5 1.79E+07 1.28E+07 1.14E+07 9.92E+06 1.31E+07 6.21E+06 1.22E+07 1.19E+07 3539969.182\n 15.4 3.12E+07 2.49E+07 2.08E+07 2.02E+07 2.28E+07 2.47E+07 2.31E+07 2.39E+07 3635170.737\n 20.5 2.98E+07 2.96E+07 2.75E+07 2.44E+07 3.10E+07 3.69E+07 2.73E+07 2.95E+07 3917515.953` But the total number of columns is variable in each file. I have to plot first column vs the two last ones... and I couldnt make your link work on these. Any idea why? (sorry data not formated) – madoro Oct 01 '15 at 09:51
  • and I'm working in windows 8 – madoro Oct 01 '15 at 09:56
  • A platform-independent gnuplot-only solution see: https://stackoverflow.com/a/72330398/7295599 – theozh Jun 15 '22 at 17:55

1 Answers1

1

An answer to Automatic series in gnuplot shows one possibility. But that doesn't work in Windows. In your special case, that all columns contain only numerical values (no time or strings), then you can use with gnuplot Version 5 the following:

stats 'mydata.txt' matrix nooutput
plot "mydata.txt" using 1:STATS_size_x

Beware, that the data you posted in a comment contains strange characters (U+200C ZERO WIDTH NON-JOINER and U+200B ZERO WIDTH SPACE) in the last column. I don't know if you also have them in your original data file, but that breaks your data.

Community
  • 1
  • 1
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • Oh, I didn´t realise of the strange characters, but indeed I've had difficulties plotting the data. How were you able to see them? – madoro Oct 05 '15 at 12:21
  • I pasted the data into a file and noticed, that gnuplot cropped the points after three digits. Then I used a hex viewer to analyze the data and saw these characters which caused gnuplot to stop parsing the value. – Christoph Oct 05 '15 at 12:35
  • it perhaps goes a little bit offtopic, but I've tried to visualize these characters with a HEx viewer (plugin for notepad++), but I don´t know what I'm searching for :( sorry, I'm kind of newbie. The fact is that I have some files that crash in gnuplot with no apparent reason, and you might have given me the first one. I'm interested on searching and replacing that characters, since I cannot plot otherwise. Any clue where to start? – madoro Oct 05 '15 at 13:22
  • I'm not sure how to replace those characters with notepad++. Maybe the extended search&replace has a notation for this, like `\u200b` or `​`. Another problem could be a Byte-orfer-mark at the beginning of the file. Try changing the encoding of the file to ANSI, via the Edit -> Encoding (or similar) menu. Maybe that removes all unwanted characters. – Christoph Oct 05 '15 at 13:58