Skip to Content.
Sympa Menu

texmacs-users - maxima plugin: plot2d with automatic ps capture to document?

Subject: mailing-list for TeXmacs Users

List archive

maxima plugin: plot2d with automatic ps capture to document?


Chronological Thread 
  • From: Albrecht Gebhardt <address@hidden>
  • To: address@hidden
  • Subject: maxima plugin: plot2d with automatic ps capture to document?
  • Date: Wed, 23 Feb 2005 10:03:47 +0100


Hi all,

I was searching if there is already some
capture-the-plot-into-the-texmacs-document function available for Maxima (as
it is for R, octave, gnuplot). It seems to be not.

So I decided to try some lisp coding:

;;
;; preliminary tmplot2d function, address@hidden
;;
(defun $tmplot2d (&rest args)
($set_plot_option '((mlist) $gnuplot_term $ps))
($set_plot_option '((mlist) $gnuplot_out_file "/tmp/tmplot.eps"))
(apply '$plot2d args)
(write (concatenate 'string (vector (code-char 2)) "ps" ":")
:escape nil :readably nil)
; TODO: something like this
;(setq plotfile (open "/tmp/tmplot.eps"))
;(format t "%s" (read plotfile))
;; ^^ should be a while loop until EOF.. don't know how to do
;(close plotfile)
; workaround:
(system "cat /tmp/tmplot.eps")
(write (concatenate 'string (vector(code-char 5)))
:escape nil :readably nil)
($set_plot_option '((mlist) $gnuplot_term $default))
($set_plot_option '((mlist) $gnuplot_out_file nil))
(print "plot done")))


Put this into plugins/maxima/lisp/texmacs-maxima-5.9.1.lisp and then in a
Maxima session call e.g.

tmplot2d(sin(x), [x, -%Pi, %Pi]);

instead of

plot2d(sin(x), [x, -%Pi, %Pi]);

It's not perfect, the plot is to large, the function should restore the plot
options instead of resetting them to default afterwards, but maybe someone
with more lisp, maxima and texmacs knowledge can inmprove it?

I tested it with the Debian sarge packages of texmacs and maxima (that means
maxima runs with GCL, don't know if my lisp code is GCL specific)

I first tried a variant without redirecting output to file:
(write (concatenate 'string (vector (code-char 2)) "ps" ":")
(apply '$plot2d args)
(write (concatenate 'string (vector(code-char 5)))

it works too, but if you generate some syntax error in the $plot2d call
(wrong
range or so) then it hangs (because the error message gets captured between
\0x02ps: .... \0x05.

Albrecht

--
// Albrecht Gebhardt Tel.: (++43 463) 2700/3118
// Institut fuer Mathematik Fax : (++43 463) 2700/3198
// Universitaet Klagenfurt mailto:address@hidden
// Universitaetsstr. 65 http://www.math.uni-klu.ac.at/~agebhard
// A-9020 Klagenfurt, Austria
// GPG PK: http://www.math.uni-klu.ac.at/~agebhard/agebhard.asc
// GPG FP: F46F 656E E83C 9323 CE30 FF8F 9DBA D1A3 B55A 78A6



Archive powered by MHonArc 2.6.19.

Top of Page