# VMT_ExportPNG

## PURPOSE

This script exports the given figure and formats it according to the

## SYNOPSIS

function VMT_ExportFIG(path,fignum,BkgdColor,AxColor,FigColor,FntSize,Res,Format)

## DESCRIPTION

    This script exports the given figure and formats it according to the
    specified properties:

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

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