Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to pause until plot window closed?

3,645 views
Skip to first unread message

Grant Edwards

unread,
Jul 22, 2008, 11:39:27 AM7/22/08
to
I want a shell script to plot a file and then allow the user to
manipulate the plot using the mouse (zoom, unzoom, etc.), and I
can't figure out how to do that.

gnuplot <<EOF
plot "$$tmp.dat" with points
pause -1
EOF

That exits immediately.

If I replace the -1 with a large number (say, 9999), then the
plot window is unresponsive. If I do a "pause mouse key", then
the plot window closes when the user tries to un-zoom. If I do
"gnuplot -persist" zooming with the mouse doesn't work.

How do I wait until the plot window closes?

Alternatively, how do I just pause forever so that the user can
kill the process with a SIGINT when he's done?

--
Grant Edwards grante Yow! ... bleakness
at ... desolation ... plastic
visi.com forks ...

mer...@chauvet.bmsc.washington.edu

unread,
Jul 22, 2008, 12:44:55 PM7/22/08
to
In article <ns6dnf9ElM-yYhjV...@posted.visi>,

Grant Edwards <gra...@visi.com> wrote:
>I want a shell script to plot a file and then allow the user to
>manipulate the plot using the mouse (zoom, unzoom, etc.), and I
>can't figure out how to do that.
>
> gnuplot <<EOF
> plot "$$tmp.dat" with points
> pause -1
> EOF
>
>That exits immediately.
>
>If I replace the -1 with a large number (say, 9999), then the
>plot window is unresponsive. If I do a "pause mouse key", then
>the plot window closes when the user tries to un-zoom.

Make a separate subroutine file that loops on 'pause mouse key'.

pause mouse key
if (MOUSE_KEY != 27) reread

The call it from the main script

print "Hit <esc> to exit"
load "loop_til_escape"

--
Ethan A Merritt

Grant Edwards

unread,
Jul 22, 2008, 2:24:49 PM7/22/08
to

I tried that, and it doesn't work. It appears to eat all of
the keypresses, so things like pressing "u" to unzoom don't
work. Here's the rather ugly kludge I came up with:

#!/bin/bash

(cat<<EOF
plot sin(x)
pause -1 "press Ctrl-D to exit"
EOF
cat /dev/tty) | gnuplot

I don't like it much, but it works.


--
Grant Edwards grante Yow! I'd like some JUNK
at FOOD ... and then I want to
visi.com be ALONE --

mer...@chauvet.bmsc.washington.edu

unread,
Jul 22, 2008, 4:12:45 PM7/22/08
to
In article <vZCdnbkYzP9suBvV...@posted.visi>,

Grant Edwards <gra...@visi.com> wrote:
>On 2008-07-22, mer...@chauvet.bmsc.washington.edu <mer...@chauvet.bmsc.washington.edu> wrote:
>> In article <ns6dnf9ElM-yYhjV...@posted.visi>,
>> Grant Edwards <gra...@visi.com> wrote:
>>>I want a shell script to plot a file and then allow the user to
>>>manipulate the plot using the mouse (zoom, unzoom, etc.), and I
>>>can't figure out how to do that.
>>>
>>> gnuplot <<EOF
>>> plot "$$tmp.dat" with points
>>> pause -1
>>> EOF
>>>
>>>That exits immediately.
>>>
>>>If I replace the -1 with a large number (say, 9999), then the
>>>plot window is unresponsive. If I do a "pause mouse key", then
>>>the plot window closes when the user tries to un-zoom.
>>
>> Make a separate subroutine file that loops on 'pause mouse key'.
>>
>> pause mouse key
>> if (MOUSE_KEY != 27) reread
>>
>> The call it from the main script
>>
>> print "Hit <esc> to exit"
>> load "loop_til_escape"
>
>I tried that, and it doesn't work. It appears to eat all of
>the keypresses, so things like pressing "u" to unzoom don't
>work. Here's the rather ugly kludge I came up with:

Ah. I misunderstood the requirements. Then you want

... oops, wait a moment,
... sigh, ...there's a bug.

well, after applying the 1 line fix below, you can simply say
pause mouse button1
leaving normal response to keys and mouse buttons 2 and 3.
That gives you zooming (button 3) and n/p/u hotkeys as usual.
The pause returns only when you click button1.
[tested on x11 and wxt; no guarantee about windows]

--- gnuplot-old/src/mouse.c 2008-07-21 13:10:43.000000000 -0700
+++ gnuplot-new/src/mouse.c 2008-07-22 13:02:29.000000000 -0700
@@ -1450,7 +1450,7 @@ event_buttonpress(struct gp_event_t *ge)
/* not bound in 2d graphs */
} else if (3 == b &&
(!replot_disabled || refresh_ok) /* Use refresh if available */
- && !(paused_for_mouse & PAUSE_CLICK)) {
+ && !(paused_for_mouse & PAUSE_BUTTON3)) {
/* start zoom; but ignore it when
* - replot is disabled, e.g. with inline data, or
* - during 'pause mouse'


--
Ethan A Merritt

0 new messages