[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Texmacs-dev] inline plots
From: |
Bill Eaton |
Subject: |
[Texmacs-dev] inline plots |
Date: |
Fri, 17 May 2013 14:40:00 -0700 |
I've already posted this to the Users mailing list. Someone suggested I
cross post here.
I'd like to solicit suggestions on how to do inline plots in various
sessions. I've already figured out how to do it in one session and it
doesn't look impossible for others.
I know this is topic comes up often, but I have found few solutions. If
you want to have a live mathematical scratchpad or notebook, its
desirable to have live inline figures. If you're using the Maxima,
Python, Octave, etc. plugin, you could invoke an extra command to
insert an inline plot.
In fact, this is already possible in the Python plugin, via the ps_out
function. This ps_out function points the way how we might do it in
other environments. Heck, maybe it's already possible in other
environments but I just don't know how. In Python, here's a minimal example:
import matplotlib
matplotlib.use('ps')
from pylab import *
fig = figure(figsize=(3,2))
ax=fig.add_subplot(111)
ax.plot([1,2,3])
ax.set_title('inline demo')
savefig('demo.eps')
ps_out('demo.eps')
So from the session, you save an EPS file and then invoke the ps_out
function to display it. The displayed plot behaves pretty well. You can
go back and change things, overwrite the EPS figure and then reinvoke
ps_out and you get a new plot. Pure magic.
I looked inside ps_out and it just spits out the EPS file plus some
extra stuff (here i use + for string concatenation:
chr(2)+'ps:'+<EPS file contents>+chr(5)
It should be easy to do the same thing in Octave. The ps_out function in
Octave could be:
function ps_out(fname)
disp( [char(2); 'ps:'; fileread(fname) ; char(5)] )
endfunction
I'm dying to test this out and add more sophisticated error checking,
but I don't know how to hack the appropriate file to look for the ps_out
function. I think it would be in tmrepl.m. If someone can suggest the
appropriate lines to modify, I would greatly appreciate and be happy to
report my findings.
Likewise, it would be really swell to have a similar functionality in
Maxima. There I have less of a clue, but I'm guessing the
texmacs-maxima-<ver>.lisp file is the one to hack. I'm willing to do
some legwork if anyone has suggestions.
--Bill Eaton
- [Texmacs-dev] inline plots,
Bill Eaton <=