[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Texmacs-dev] Maxima inline plots
From: |
Marduk Bolaños |
Subject: |
Re: [Texmacs-dev] Maxima inline plots |
Date: |
Tue, 05 Sep 2017 18:45:00 +0000 |
User-agent: |
astroid/v0.9.1-10-gfea7a92d (https://github.com/astroidmail/astroid) |
Dear all,
I am happy to tell you that I solved it. Now we can have LabView-style
plots in the sense that one can switch between the plot and the code
behind it. This also enables one to have reproducible plots.
So here is the code:
In maxima-menus.scm change this function (actually this was the culprit)
(tm-define (plugin-output-simplify name t)
(:require (== name "maxima"))
;;(display* "Simplify output " t "\n")
(if (func? t 'document)
(with u (list-find (cdr t) maxima-contains-prompt?)
;; Changed "" to (maxima-output-simplify t)
(if u (maxima-output-simplify u) (maxima-output-simplify t)))
(maxima-output-simplify t)))
In texmacs-maxima.lisp add:
(defun tm_out (raw_data)
(let ((beg (string (code-char 2)))
(end (string (code-char 5))))
(concatenate 'string beg "ps:" raw_data end)))
(defmfun $ps_out (filename)
(with-open-file (stream (concatenate 'string $maxima_tempdir "/" filename))
(let ((contents (make-string (file-length stream))))
(read-sequence contents stream)
;; princ does not enclose the string in quotes
(princ (tm_out contents))
(princ ""))))
(defmfun $ps_plot2d (&rest args)
#$set_plot_option([gnuplot_term, ps])$
#$set_plot_option([gnuplot_out_file, "plot.ps"])$
(apply '$plot2d args))
In my-init-texmacs.scm:
(kbd-map
("A-." (make-session "maxima" "default"))
("A-f" (begin (insert-go-to `(script-input "maxima" "default" "ps_out(\"plot.ps\")"
"") '(2 0))
(set-pretty-preference "automatic quotes" "Disabled")))
)
I use it like this:
+ Insert a big figure
+ A-f A-.
+ Plot something in Maxima
+ Toggle the script to show the plot/show the Maxima code
Of course, this procedure also works with other languages and even with
equations. So no more "after a long calculation that I will not show you
and maybe the result is wrong".
Let's bring scientific authoring to the 21st century!
P.S.
This solves Bill Eaton's enquiry from 2013
https://lists.gnu.org/archive/html/texmacs-dev/2013-05/msg00024.html