# v_figbolden

## PURPOSE

V_FIGBOLDEN embolden, resize and recolour the current figure =(POS,PV,M)

## SYNOPSIS

function v_figbolden(pos,pv,m)

## DESCRIPTION

    V_FIGBOLDEN embolden, resize and recolour the current figure =(POS,PV,M)

     Inputs: pos = [xmin ymin width height] gives the lower left corner position and the window size in pixels
                   [width height] leaves the lower left corner alone
                   [width] has a standard aspect ratio of 4:3
                   [-width/height] leaves the area unchanged but fixes the aspect ratio
             pv is a cell name containing attribute-value pairs.
                default = {'FontName' 'Arial'; 'FontSize' 16; 'LineWidth' 2; 'MarkerSize' 8}
                Note that the "listfonts" MATLAB command will list the available fonts
             m is a mode string:
                    'l' lists the changes made
                    'd' append default pv settings (e.g. use [] for second argument)
                    'c' change default colours to improve contrast on a white background
                        g->[0,0.7,0],c->[0,0.7,0.7],y->[0.83,0.83,0]
                    'x' suppresses all changes

     Bug: gives an error message if log axes have been used

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- v_fig2emf V_FIG2EMF save a figure in windows metafile format (H,S,P)
- v_fig2pdf V_FIG2EMF save a figure in pdf/eps/ps formats (H,S,P,F)

## SOURCE CODE

    0001 function v_figbolden(pos,pv,m)
    0002 %V_FIGBOLDEN embolden, resize and recolour the current figure =(POS,PV,M)
    0003 %
    0004 % Inputs: pos = [xmin ymin width height] gives the lower left corner position and the window size in pixels
    0005 %               [width height] leaves the lower left corner alone
    0006 %               [width] has a standard aspect ratio of 4:3
    0007 %               [-width/height] leaves the area unchanged but fixes the aspect ratio
    0008 %         pv is a cell name containing attribute-value pairs.
    0009 %            default = {'FontName' 'Arial'; 'FontSize' 16; 'LineWidth' 2; 'MarkerSize' 8}
    0010 %            Note that the "listfonts" MATLAB command will list the available fonts
    0011 %         m is a mode string:
    0012 %                'l' lists the changes made
    0013 %                'd' append default pv settings (e.g. use [] for second argument)
    0014 %                'c' change default colours to improve contrast on a white background
    0015 %                    g->[0,0.7,0],c->[0,0.7,0.7],y->[0.83,0.83,0]
    0016 %                'x' suppresses all changes
    0017 %
    0018 % Bug: gives an error message if log axes have been used
    0019
    0020 %      Copyright (C) Mike Brookes 2003
    0021 %      Version: $Id: v_figbolden.m 10865 2018-09-21 17:22:45Z dmb $
    0022 %
    0023 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0024 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0025 %
    0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0027 %   This program is free software; you can redistribute it and/or modify
    0028 %   it under the terms of the GNU Lesser General Public License as published by
    0029 %   the Free Software Foundation; either version 3 of the License, or
    0030 %   (at your option) any later version.
    0031 %
    0032 %   This program is distributed in the hope that it will be useful,
    0033 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0034 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0035 %   GNU Lesser General Public License for more details.
    0036 %
    0037 %   You can obtain a copy of the GNU Lesser General Public License from
    0038 %   https://www.gnu.org/licenses/ .
    0039 %
    0040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0041
    0042 ps={'Title' 'XLabel' 'YLabel' 'Children'};
    0043 if nargin<3
    0044     m='';
    0045 end
    0046 if nargin<2 || any(m=='d')
    0047     pv={'FontName' 'Arial'; 'FontSize' 16; 'LineWidth' 2; 'MarkerSize' 8};
    0048 end
    0049 pp={'Symbol';'Wingdings'};      % protected fonts
    0050 if nargin<1
    0051     pos=[];
    0052 end
    0053 mlist=any(m=='l');  % list changes
    0054 mnotx=~any(m=='x'); % do changes
    0055 scsz=get(0,'screensize');
    0056 if length(pos)
    0057     po=get(gcf,'position');
    0058     if length(pos)>2            % position is specified
    0059         po(1:2)=pos(1:2);
    0060         pos(1:2)=[];      % remove xmin,ymin
    0061     end
    0062     if length(pos)>1
    0063         po(3:4)=pos(1:2);
    0064     else
    0065         if pos(1)>0
    0066             po(3:4)=[1 0.75]*pos(1);
    0067         else
    0068             po(3:4)=[-pos(1) 1]*sqrt(-po(3)*po(4)/pos(1)); % preserve area
    0069         end
    0070     end
    0071     set(gcf,'position',po);
    0072 end
    0073 if any(m=='c')
    0074     cc='gcy';
    0075     cv=[0,0.7,0;0,0.7,0.7;0.83,0.83,0];
    0076     for ic=1:3
    0077         hlist=findobj(gcf,'color',cc(ic));
    0078         if length(hlist)
    0079             if mnotx
    0080                 set(hlist,'color',cv(ic,:));
    0081             end
    0082             if mlist
    0083             for ih=1:length(hlist)
    0084                  fprintf(['change %f Color: ''%c'' -> [%g %g %g]\n'],hlist(ih),cc(ic),cv(ic,:));
    0085             end
    0086             end
    0087         end
    0088     end
    0089 end
    0090 hlist=get(gcf,'children');
    0091 while length(hlist)
    0092     pl=get(hlist(1));
    0093     %fprintf('list length = %d, handle = %f\n',length(hlist),hlist(1));
    0094     for i=1:size(pv,1)
    0095         if isfield(pl,pv{i,1})
    0096             if i>1 || all(~strcmpi(get(hlist(1),pv{i,1}),pp))
    0097                 pval=get(hlist(1),pv{i,1});
    0098                 if ~all(size(pval)==size(pv{i,2})) || ~all(pval(:) == pv{i,2}(:))
    0099                     if mnotx
    0100                         set(hlist(1),pv{i,1},pv{i,2})
    0101                     end
    0102                     if mlist
    0103                         if ischar(pval)
    0104                             fch='s';
    0105                         else
    0106                             fch='g';
    0107                         end
    0108                         fprintf(['change %f %s: %' fch ' -> %' fch '\n'],hlist(1),pv{i,1},pval,pv{i,2});
    0109                     end
    0110                 end
    0111             end
    0112         end
    0113     end
    0114     for i=1:length(ps)
    0115         if isfield(pl,ps{i})
    0116             hlist=[hlist; get(hlist(1),ps{i})];
    0117             %fprintf('add %f:%s\n',hlist(1),ps{i});
    0118         end
    0119     end
    0120     hlist(1)=[];
    0121 end
    0122