Author Topic: Gnuplot Question  (Read 3179 times)

michael21NEW

  • Newbie
  • *
  • Posts: 3
    • View Profile
Gnuplot Question
« on: January 26, 2006, 11:24:41 am »
Hi,

i am new here, so i really do not know where to post this. Hope i'm right here.

My question is:
Is there any possibility how to plot only the last (let's say 50) values (rows) from an external file using GNUPLOT ?

something like: p [last-50:last] 'data.txt' u 1:2 w l  ??????


I hope someone knows the answer - if there is any.

Thanks in advance for trying to answer.

Best regards
Michael

jbruno

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • http://
Gnuplot Question
« Reply #1 on: January 26, 2006, 11:28:58 am »
Quote
Hi,

i am new here, so i really do not know where to post this. Hope i'm right here.

My question is:
Is there any possibility how to plot only the last (let's say 50) values (rows) from an external file using GNUPLOT ?

something like: p [last-50:last] 'data.txt' u 1:2 w l  ??????


I hope someone knows the answer - if there is any.

Thanks in advance for trying to answer.

Best regards
Michael
[div align=\"right\"][a href=\"index.php?act=findpost&pid=112508\"][{POST_SNAPBACK}][/a][/div]
-----
SL6000L
ATP 512MB SD

jbruno

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
    • http://
Gnuplot Question
« Reply #2 on: January 26, 2006, 11:30:53 am »
It looks like the input is a text file, so even if Gnuplot doesn't support what you want, you could run:

Code: [Select]
tail -n 50 data.txt > last50.txt

And then use last50.txt

Quote
Hi,

i am new here, so i really do not know where to post this. Hope i'm right here.

My question is:
Is there any possibility how to plot only the last (let's say 50) values (rows) from an external file using GNUPLOT ?

something like: p [last-50:last] 'data.txt' u 1:2 w l  ??????


I hope someone knows the answer - if there is any.

Thanks in advance for trying to answer.

Best regards
Michael
[div align=\"right\"][a href=\"index.php?act=findpost&pid=112508\"][{POST_SNAPBACK}][/a][/div]
-----
SL6000L
ATP 512MB SD

michael21NEW

  • Newbie
  • *
  • Posts: 3
    • View Profile
Gnuplot Question
« Reply #3 on: January 26, 2006, 11:39:08 am »
Thanks for the really fast answers.

I didn't know that one too. But this doesn't solve the whole problem.

The text file is the output of a program, and so there are new entries all the time. I would like to watch them in gnuplot.

Now i am using gnuplot4. Here it is possible to refresh the data with the keys "A" or "E". That ok but it either has a fixed view, or it resizes the whole view to see the whole graph.

I need too see the last entries only. Like "moving" the graph "to the right" without changing the "zoom".

Michael

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Gnuplot Question
« Reply #4 on: January 26, 2006, 01:10:09 pm »
You'd be better looking at specific gnuplot resources, their mailing list/irc channel for example,


Si
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

datajerk

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • http://
Gnuplot Question
« Reply #5 on: January 26, 2006, 07:49:14 pm »
Quote
Thanks for the really fast answers.

I didn't know that one too. But this doesn't solve the whole problem.

The text file is the output of a program, and so there are new entries all the time. I would like to watch them in gnuplot.

Now i am using gnuplot4. Here it is possible to refresh the data with the keys "A" or "E". That ok but it either has a fixed view, or it resizes the whole view to see the whole graph.

I need too see the last entries only. Like "moving" the graph "to the right" without changing the "zoom".

Michael
[div align=\"right\"][{POST_SNAPBACK}][/a][/div]
I do this with a combination of expect and gnuplot.  You need to write an expect script that will:

1.  Startup gnuplot
2.  tail -50 data >data.50
3.  send gnuplot: plot 'data.50'
4.  tail -50 data >data.50
5.  send gnuplot: replot
6.  sleep
7.  goto 4.

Examples:

data.expect:

#!/usr/bin/expect

system tail -50 data >data.50
spawn gnuplot data.gnuplot -

while {1} {
  sleep 1
  system tail -50 data >data.50
  expect ">"
  send "replot\r" #replot will keep the geometry but adjust the plot axis to match data unless you use set range commands.
}

data.gnuplot:

plot "data.50" with linespoints

For more advanced functions like interaction (A and E keys) use the expect "interact" statements.  Get the book "Exploring Expect".  You can get expect/tcl here (you need tcl for expect):

[a href=\"http://sense.net/zc/files/]http://sense.net/zc/files/[/url]

An an X/QT version of gnuplot 4 I built here:

http://sense.net/zc/gnuplot/

michael21NEW

  • Newbie
  • *
  • Posts: 3
    • View Profile
Gnuplot Question
« Reply #6 on: January 27, 2006, 05:45:51 am »
thanks very much.
i think this will do it.  

Michael