[vslist] Re: Plotting, for the matlab tweakers...

P. George Lovell p.g.lovell@bristol.ac.uk
Wed Jul 28 08:22:31 2004


Hi,

One of the most annoying things about matlab plots is the fact that 
the thickness of lines is always too small and the text is usually 
too small too.

A long while ago I wrote some code which extends the 'set' command to 
do hierarchical setting of property attributes. So you can resize all 
text objects by +2 pica or whatever. It does font size by default, 
but you can set values for any attribute in the properties list, for 
example setting all linewidths to 2 rather than the usual skinny 
0.25.

You type:-

	setprop(gcf, +2) % to increase the size of all text in the window.
	setprop(gca, +2) % to increase the size of all text in an axes...

Rather than attach the code which will probably get lost, I've just 
pasted in the source below. Cut and paste it into a file called 
setprop.m, save it in your matlab path.

George







%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matlab Code begins
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function handles = setprop(varargin)
% change values of any child item with the specified property
% As a default the property is taken to be 'FontSize'
%
% Acceptable input formats:-
%
% format : handles = setprop(parenthandle,sizechange);
% or
% format : handles = setprop(sizechange);
% or 
% format : handles = setprop(propertyname,value);
% or
% format : handles = setprop(parenthandle,propertyname,value);
%
% (c) George Lovell, 1999. University of Stirling.

% uses current figure as default
if length(varargin) > 3; nochildren = 1; varargin={varargin{1:3}}; end
switch length(varargin)
case 1 % (1) sizechange
   
   hdl = gca;
   sizechange = varargin{1};
   property = 'fontsize';
   varyfontsize = 1;
   
case 2 %    (1) parent handle (2) sizechange
   		% or (1) property      (2) value
   
   if ishandle(varargin{1})
      hdl = varargin{1};
      sizechange	= varargin{2};
      property	= 'FontSize';
      varyfontsize = 1;
      
   elseif isstr(varargin{1})
      property	= varargin{1};
      value		= varargin{2};
      hdl			= gca;   
      varyfontsize = 0;
   end
   
   
case 3 % (1) parent handle (2) property (3) value
   hdl		= varargin{1};
   property	= varargin{2};
   value		= varargin{3};
   if ~ishandle(hdl); error('First argument must be handle(s)'); end
	varyfontsize = 0;
   
otherwise
   error('incorrect number of input arguments');
end

% Get all handles below and including hdl
	if iscell(hdl); hdl = cat(1,hdl{:}); end
	newchildren	= hdl;
	allhandles	= [];
   while ~isempty(newchildren)
      if iscell(newchildren); newchildren = cat(1,newchildren{:}); end
      allhandles = [allhandles;newchildren];
      newchildren = allchild(newchildren);
   end
   
   property = lower(property);
   
   % Do the items who's handles we've found have the property
   changehandles = [];
   for hdl = allhandles'
      if sum(strcmp(lower(fieldnames(get(hdl))),property))
         changehandles(end+1) = hdl;
      end
   end
   
   if varyfontsize
	   values = get(changehandles,'fontsize');
	   if iscell(values); values  = cat(1,values{:}); end
      values = values + sizechange;
      values = num2cell(values);
   else
      values = repmat({value},size(changehandles));
   end
   
   for tcount = 1:length(changehandles)
      set(changehandles(tcount),property,values{tcount});
   end

   if nargout < 1
      clear texthandles;
   end
   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Code ends
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      






On 27 Jul 2004 at 11:42, giedrius@salk.edu wrote:

> Dear David, 
> 
> select the figure for exporting to postscript and use the print 
command:
> figure(figure#)
> print -dpsc2 fileName
> 
> this will create fileName.ps file in the current directory.
> best-
> Giedrius
> 
>    Giedrius T. Buracas, Ph.D.       giedrius@salk.edu              
^
>    Center for Functional Magnetic Resonance Imaging
>    University of California, San Diego
>    9500 Gilman Drive,  Mail code 0677
>    La Jolla, CA 92093
>    Phone: (858) 822-0519
>    Fax: (858) 822-0605
> 
> ___________
> Hi all, 
> 
> Has anybody figured out how to make Matlab export plots as colour 
postscript 
> files? 
> 
> Regards, David 
> 
> 
> 
> _______________________________________________
> http://www.visionscience.com/mailman/listinfo/vslist


-----
Dr P. George Lovell,
Department of Experimental Psychology,
University of Bristol,
Bristol, BS8 1TN
phone : (0117) 9288581
email  : p.g.lovell@bris.ac.uk