# VMT_ExportFIG

## PURPOSE

Exports the given figure and formats it according to the

## SYNOPSIS

function VMT_ExportFIG(savepath,to_export,BkgdColor,AxColor,FigColor,FntSize,Res,Format)

## DESCRIPTION

     Exports the given figure and formats it according to the
     specified properties:

     BkgdColor: Background Color (outside of figure space)
     AxColor:   Axes Color
     FigColor:  Figure window color (inside figure Space)
     FntSize:   Fontsize for axes labels and title
     Res:       resolution (dpi)
     Format:    'png' or 'eps'

     P.R. Jackson, USGS, 8-6-12
     Last modified: F.L. Engel 2/20/2013

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- VMT_SaveFigs Saves the figures (specified by fignums) from VMT as .PNG or EPS files

## SOURCE CODE

    0001 function VMT_ExportFIG(savepath,to_export,BkgdColor,AxColor,FigColor,FntSize,Res,Format)
    0002 % Exports the given figure and formats it according to the
    0003 % specified properties:
    0004 %
    0005 % BkgdColor: Background Color (outside of figure space)
    0006 % AxColor:   Axes Color
    0007 % FigColor:  Figure window color (inside figure Space)
    0008 % FntSize:   Fontsize for axes labels and title
    0009 % Res:       resolution (dpi)
    0010 % Format:    'png' or 'eps'
    0011 %
    0012 % P.R. Jackson, USGS, 8-6-12
    0013 % Last modified: F.L. Engel 2/20/2013
    0014
    0015 % Make figure current focus
    0016 hf = figure(findobj('name',to_export));
    0017 figure(hf);
    0018 set(gcf, 'PaperPositionMode', 'auto');
    0019 box on
    0020 if ~isempty(BkgdColor)
    0021     set(gcf,'Color',BkgdColor);
    0022 end
    0023
    0024 if ~isempty(FntSize)
    0025     set(gca,'FontSize',FntSize)
    0026     set(get(gca,'Title'),'FontSize',FntSize)
    0027 end
    0028
    0029 if ~isempty(FigColor)
    0030     set(gca,'Color',FigColor)
    0031 end
    0032
    0033 if ~isempty(AxColor)
    0034     set(gca,'XColor',AxColor)
    0035     set(gca,'YColor',AxColor)
    0036     set(gca,'ZColor',AxColor)
    0037     set(findobj(gcf,'tag','Colorbar'),'FontSize',FntSize,'XColor',AxColor,'YColor',AxColor);
    0038     set(get(gca,'Title'),'FontSize',FntSize,'Color',AxColor)
    0039     set(get(gca,'xLabel'),'FontSize',FntSize,'Color',AxColor)
    0040     set(get(gca,'yLabel'),'FontSize',FntSize,'Color',AxColor)
    0041 end
    0042
    0043 set(gcf,'InvertHardCopy','off')
    0044
    0045 %Save the figure
    0046
    0047 switch Format
    0048     case 'png'
    0049         [file,pathname] = uiputfile('*.png',[to_export ' Export'],savepath);
    0050         fileout = [pathname file];
    0051         %fileout = [path '_Figure' num2str(fignum)];
    0052         %disp(fileout)
    0053         set(gcf, 'PaperPositionMode', 'auto');
    0054         print(hf,'-dpng', '-noui', '-painters',['-r' num2str(Res)],fileout)
    0055     case 'eps'
    0056         [file,pathname] = uiputfile('*.eps',[to_export ' Export'],savepath);
    0057         fileout = [pathname file];
    0058         %fileout = [path '_Figure' num2str(fignum)];
    0059         %disp(fileout)
    0060         set(gcf, 'PaperPositionMode', 'auto');
    0061         print(hf,'-depsc', '-noui', '-painters',['-r' num2str(Res)],fileout)
    0062     % Default
    0063     otherwise
    0064         [file,pathname] = uiputfile('*.png',[to_export ' Export'],savepath);
    0065         fileout = [pathname file];
    0066         %fileout = [path '_Figure' num2str(fignum)];
    0067         %disp(fileout)
    0068         set(gcf, 'PaperPositionMode', 'auto');
    0069         print(hf,'-dpng', '-noui', '-painters',['-r' num2str(Res)],fileout)
    0070 end
    0071
    0072
    0073
    0074
    0075
    0076