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!

6
  • 1
    See e.g. stackoverflow.com/a/32826047/2604213 Commented Sep 29, 2015 at 14:48
  • Unfortunately I could not make this work, is there really not a reverse counting in gnuplot? Commented Oct 1, 2015 at 8: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. Commented Oct 1, 2015 at 9: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) Commented Oct 1, 2015 at 9:51
  • and I'm working in windows 8 Commented Oct 1, 2015 at 9:56

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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?
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.
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?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.