PostScript print function

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PostScript print function

mduncan
This is what seems to work for me.  It's basically the same thing Jonathan Hill
described, but in a function.  Without and input argument it just sends the
postscript directly to the printer via a temp file and a system call (you'd
replace the "lpr " with the appropriate system print command of, of course).
Otherwise it's written to the specified file.  The plot is brought back to the
X term at the end, and the temp file (if any) is removed.

Hope it's useful,

mike


my print.m file:  

  function print(file)

  if nargin < 1, file='tmp.ps'; end
  eval(['gset term postscript']);
  eval(['gset output "',file,'"'])
  replot;
  if nargin < 1, system(['lpr ',file]); end
  eval(['gset term x11']);
  replot;
  if nargin < 1, system('rm tmp.ps'); end


----------------------------------
Mike Duncan
Planning Systems Inc.
Ph: 504-639-3537
Fx: 504-649-0480
E-Mail: [hidden email]
Date: 23-Jun-98
Time: 14:45:18
----------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: PostScript print function

John Logsdon-4
Just a point to add that if the plot is  very large, you cannot remove the
file at the end of the script since it is still be piped to.  (Please
excuse the preposition at the end).

On my (by now) slow 486/100 and 586/133, which have done a mountain of
Octaving in the last year, I use the function below that also prompts for
a filename if it is not given (hence enabling you to store the files for
LaTeX etc work later).

I have therefore added an optional sleep to enable the process to be
completed and also to enable the preparation of postscript files alone
since there are times when I don't want to occupy my printer either!

No doubt there are more elegant ways of skinning this cat ...

John

Centre for Applied Statistics
Lancaster University

function [_plotname]=printplot(filename,sl)
%
% function [_plotname]=printplot(filename,sl)
% Function to plot a file on the screen
% if sl>0 then it sleeps for sl seconds
% if sl<0 then no printing is done, only a postscipt file prepared
%
if nargin<1
  _plotname=input("Enter name of file to store data in ","s");
else
  _plotname=filename;
end
gset term postscript
eval(["gset output """,_plotname,""""]);
replot
if nargin==1
  sl=0;
end
if sl>0
  message = sprintf("Sleeping for %d seconds ...\n",sl)
  sleep(sl);
end
gset term X11;
replot;
if sl>=0
  eval(["system(""lpr ",_plotname,""");"]);
end
endfunction



Reply | Threaded
Open this post in threaded view
|

Re: PostScript print function

Andreas Kratzert
John Logsdon wrote:

>
> Just a point to add that if the plot is  very large, you cannot remove the
> file at the end of the script since it is still be piped to.  (Please
> excuse the preposition at the end).
>
> On my (by now) slow 486/100 and 586/133, which have done a mountain of
> Octaving in the last year, I use the function below that also prompts for
> a filename if it is not given (hence enabling you to store the files for
> LaTeX etc work later).
>
> I have therefore added an optional sleep to enable the process to be
> completed and also to enable the preparation of postscript files alone
> since there are times when I don't want to occupy my printer either!
>
> No doubt there are more elegant ways of skinning this cat ...
>
> John
>
> Centre for Applied Statistics
> Lancaster University
>
> function [_plotname]=printplot(filename,sl)
In my print-function I simply use

  gset out "| lpr"

for sending the output to the printer.
-> no temp file and no sleeping neccessary.


--
Andreas Kratzert                 Tel.  +49 9131 85-7610
Lehrstuhl Technische Elektronik  Fax.  +49 9131 302951
Cauerstr. 9                      Email [hidden email]
91058 Erlangen            http://www.lte.e-technik.uni-erlangen.de/~kzt/


Reply | Threaded
Open this post in threaded view
|

"print" in multiplot mode (was Re: PostScript print function)

jsg-2


   In message <[hidden email]>, you write:
 
| John Logsdon wrote:

<delete>

| >
| >
| > function [_plotname]=printplot(filename,sl)
| In my print-function I simply use
|
|   gset out "| lpr"
|
| for sending the output to the printer.
| -> no temp file and no sleeping neccessary.

What about in multiplot mode... is there a way to generate a
postscript file of a multiplot mode graph once it has been displayed
on the screen?

example:

========== cut here =================
octave:25> multiplot(1,2)
octave:26> subplot(211)
octave:27> plot([1 5;2 4],'-')
octave:28> gset out "| lpr"     %same error for "gset term postscript" too
octave:29>
gnuplot> set out "| lpr"
             ^
         line 0: you can't change the output in multiplot mode
========== cut here =================

John

---------------------------------------------------------
                                John S Gwynne, PhD.
Mission Research Corporation    Email: [hidden email]
3975 Research Blvd              Tel: (937) 429-9261
Dayton Ohio 45430-2625          Fax: (937) 429-2625
---------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: "print" in multiplot mode (was Re: PostScript print function)

John Logsdon-4


On Wed, 24 Jun 1998 [hidden email] wrote:

>    In message <[hidden email]>, you write:
>  
> | In my print-function I simply use
> |
> |   gset out "| lpr"
> |
> | for sending the output to the printer.
> | -> no temp file and no sleeping neccessary.
>

yes I used stdout this way but you have to replot it later for LaTeX or
whatever ...

> What about in multiplot mode... is there a way to generate a
> postscript file of a multiplot mode graph once it has been displayed
> on the screen?
>

The version  of gnuplot I use doesn't support multiplot ('cos I am too
lazy to download it!) but I have used mpage quite effectively to put
multiple postscript plots on a single page.

John