guicho271828 / eazy-gnuplot

Super Duper Doopa Booka Lispy Gnuplot library
http://guicho271828.github.io/eazy-gnuplot/
63 stars 8 forks source link

interactive terminal #8

Closed kisp closed 9 years ago

kisp commented 9 years ago

Is it possible to use eazy-gnuplot with an interactive terminal? How would you do that?

guicho271828 commented 9 years ago

I havnt tested it, but consider using *query-io* as an argument to with-plots.

oh, you are interested in making it available from shell command line? if that's the case, take a look at https://github.com/snmsts/roswell/wiki/2.-Roswell-as-a-Scripting-Environment , which I am editing frequently recently. it is interesting if eazy-gnuplot is invokable interactively from the command line.

mmaul commented 9 years ago

Killian, Were you perhaps wanting to bring up a plotting window? If that is what you were after use the following parameters in your plot command. :terminal '(:wxt :persist t)

Works in linux, and OSX I believe, needs gnuplot 4.4 or >, Another terminal type is :x11, wxt is much better though

On Tue, Sep 29, 2015 at 5:34 AM, Masataro Asai notifications@github.com wrote:

I havnt tested it, but consider using query-io.

oh, you are interested in making it available from shell command line? if that's the case, take a look at https://github.com/snmsts/roswell/wiki/2.-Roswell-as-a-Scripting-Environment . it is interesting if eazy-gnuplot is invokable interactively from the command line.

— Reply to this email directly or view it on GitHub https://github.com/guicho271828/eazy-gnuplot/issues/8#issuecomment-144006201 .

guicho271828 commented 9 years ago

I didn't know that wxt works with eazy-gnuplot! :)

guicho271828 commented 9 years ago

um, t doesn't seem necessary.

mmaul commented 9 years ago

It might not be, but on my Linux setup I think the plot would display then exit straight away either that or I did it for some other reason I can't remember right now.

On Tue, Sep 29, 2015 at 12:46 PM, Masataro Asai notifications@github.com wrote:

um, persist doesn't seem necessary.

— Reply to this email directly or view it on GitHub https://github.com/guicho271828/eazy-gnuplot/issues/8#issuecomment-144117134 .

guicho271828 commented 9 years ago

sorry, persist is necessary, I meant t does not seem necessary. (it seems you are reading on email, not on github)

kisp commented 9 years ago

Hi, thanks for your ideas!

I am in fact looking for bringing up a plotting window. I am getting better results with pause mouse button1; than persist, because the gnuplot process is kept alive and zooming works (using mouse button3).

Something like this works nicely:

(eazy-gnuplot:with-plots (*standard-output* :debug t)
  (eazy-gnuplot:gp-setup :terminal '(:qt))
  (format t "~&plot sin(x);~%")
  (format t "pause mouse button1;~%"))

And also here (how it should be):

(eazy-gnuplot:with-plots (*standard-output* :debug t)
  (eazy-gnuplot:gp-setup :terminal '(:qt))
  (eazy-gnuplot:func-plot "sin(x)") 
  (format t "~&pause mouse button1;~%"))

Unfortunately, the most interesting version

(eazy-gnuplot:with-plots (*standard-output* :debug t)
  (eazy-gnuplot:gp-setup :terminal '(:qt))
  (eazy-gnuplot:plot (lambda ()
                       (format t "~&~A ~A" 1 2)
                       (format t "~&~A ~A" 2 5)
                       (format t "~&~A ~A" 3 4)))
  (format t "~&pause mouse button1;~%"))

fails, because the pause mouse button1; command interferes with the plot data.

It would be nice for "unsupported commands" to have a way to insert them at the end.

guicho271828 commented 9 years ago

It would be nice for "unsupported commands" to have a way to insert them at the end.

It seems you are using a slightly older version. eazy-gnuplot used to store the function to a list and execute them just before exiting with-plots, thus preventing you from inserting pause mouse button1; at the end.

In the latest version, all functions are evaluated in-place, so your last script should work. To get the latest version you have to update your quicklisp dist.

kisp commented 9 years ago

I'm getting

CL-USER> (eazy-gnuplot:with-plots (*standard-output* :debug t)
           (eazy-gnuplot:gp-setup :terminal '(:qt))
           (eazy-gnuplot:plot (lambda ()
                                (format t "~&~A ~A" 1 2)
                                (format t "~&~A ~A" 2 5)
                                (format t "~&~A ~A" 3 4)))
           (format t "~&pause mouse button1;"))
set output 
set terminal qt
plot '-'
pause mouse button1;
1 2
2 5
3 4
end
set output
; sh -c 'gnuplot'
WARNING: Process 16546 does not exist -- maybe already killed?
""
"
gnuplot> plot '-'
              ^
         line 1: Bad data on line 1 of file -

gnuplot> 1 2
         ^
         line 1: invalid command

gnuplot> 2 5
         ^
         line 1: invalid command

gnuplot> 3 4
         ^
         line 1: invalid command

gnuplot> end
         ^
         line 1: invalid command

"
(1 NIL NIL NIL NIL NIL NIL 256)
CL-USER> 

with version 17bedcf

guicho271828 commented 9 years ago

testing this now.

guicho271828 commented 9 years ago

This is an incorrect handling by eazy-gnuplot. working on this.

(btw, the version of gnuplot on my ubuntu14.04LTS doesnt seem to support qt and I cannot test if qt window actually appear when this is fixed. however, that's not the core of the problem itself.)

guicho271828 commented 9 years ago

fixed in ab44422b70c01d6d3f8a18aa2d2865afe8cc0f18 .

guicho271828 commented 9 years ago

persist allows wxt terminal to remain after returning from the function, however in my particular versions of gnuplot, it leaves a zombie process. This should be noted, since 14.04 is an LTS.

anranyicheng commented 2 years ago

Hi, to use eazy-gnuplot with an interactive terminal, the best way is using uiop:launch-program, or sb-ext:run-program with :wait key word. and this library seems to be aimed at exporting png files.

anranyicheng commented 2 years ago

By the way, if use uiop:launch-program, please pay attention to explicitly closing the process, like "quit",or exit.