is it possible to display plots in an emacs buffer?

david.whiting at david.whiting at
Sat May 22 18:26:38 CEST 2004

Perpetuating my own sub-thread...

Adding (delete-other-windows) to the function gives the plot the whole
frame, which looks better.  To remove the plot and get back to the the R
prompt just press 'q'.

(defun R-plot-w3m ()
  (setq ess-command (comint-get-old-input-default))
  (ess-execute "png('/tmp/temp.png')")
  (ess-execute ess-command)
  (ess-execute "")
  (w3m-goto-url "file:///tmp/temp.png")

Here's an example of running R-plot-w3m when the cursor in the R buffer
is on a line that contains: plot(1:10)


On Fri, May 21, 2004 at 11:53:02PM +0000, david.whiting at wrote:
> On Fri, May 21, 2004 at 05:48:31PM +0000, David Whiting wrote:
> [...]
> > If all you want to do is display a plot, then you could create a png
> > file and then display that using w3m:
> > 
> > (w3m-goto-url "file:///myplot.png")
> > 
> > At the moment this is still probably more work than you would want it to
> > be, though.
> If you have w3m working with emacs this function might do what you
> want. Bind it to a key combination and it might be less work than
> closing an X11 window.  It assumes that the line you are on when you
> call this function is one that creates a plot.
> (defun R-plot-w3m ()
>   "Display an R plot in an emacs buffer using w3m to produce the display."
>   (interactive)
>   (setq ess-command (comint-get-old-input-default))
>   (ess-execute "png('/tmp/temp.png')")
>   (ess-execute ess-command)
>   (ess-execute "")
>   (w3m-goto-url "file:///tmp/temp.png"))
> This seems to work okay for simple plots, but is giving me some issues
> with lattice graphics.  This version is designed to demonstrate an idea
> and needs more work to be really useful. 
> Dave
David Whiting
Adult Morbidity and Mortality Project (AMMP)
PO Box 65243, Aga Khan Foundation Building - Ground Floor
Plot No 344 Urambo Street, Upanga, Dar es Salaam, Tanzania.

Tel: +255 22 2153388, Fax: +255 22 2153385
AMMP website:

Against MS attachments. Why? See for example:

More information about the ESS-help mailing list