latexfigure: the code

note, this is only the code of the initial release – very likely the code has changed already.

clf; clc; clear all;
 
figure_width  = 8*2;
figure_height = 6*2;
FontSize = 11*1.5;
FontName = 'MyriadPro-Regular';
 
xaxis = linspace(0,10,50);
data1 =sin(xaxis);
data2 =sin(xaxis + 0.6);
data3 =sin(xaxis + 1.2);
 
hfig  = figure(1); clf;
    set(gcf, 'units', 'centimeters', 'pos', [0 0 figure_width figure_height])
    % set(gcf, 'Units', 'pixels', 'Position', [100 100 500 375]);
    set(gcf, 'PaperPositionMode', 'auto');
    set(gcf, 'Color', [1 1 1]); % Sets figure background
    set(gca, 'Color', [1 1 1]); % Sets axes background
    set(gcf, 'Renderer', 'painters'); 
 
hLine1 = line(xaxis, data1);
hLine2 = line(xaxis, data2);
hLine3 = line(xaxis, data3);
hdots = line(xaxis, data3);
 
 
set(hLine1                        , ...
  'LineStyle'       , '--'        , ...
  'LineWidth'       , 2           , ... 
  'Color'           , [0.75 0 0]  );
 
set(hLine2                        , ...
  'LineStyle'       , ':'         , ...
  'LineWidth'       , 2           , ...   
  'Color'           , [0 0 0.75]  );
 
set(hLine3                        , ...
  'LineStyle'       , '-'         , ...
  'LineWidth'       , 2           , ...   
  'Color'           , [0.5 0 0.5]  );
 
set(hdots                         , ...
  'LineStyle'       , 'none'      , ...
  'Marker'          , 'o'         , ...
  'MarkerSize'      , 6           , ...
  'MarkerEdgeColor' , [.5 .0 .5]  , ...
  'MarkerFaceColor' , [.7 .5 .7]  );
 
 
hTitle  = title ('test graphics');
hXLabel = xlabel('x-axis');
hYLabel = ylabel('y-axis');
 
hLegend = legend( ...
  [hdots, hLine1, hLine2, hLine3], ...
  'Data' , ...
  'Model'    , ...  
  'Fit'      , ...
  'Validation Data'       , ...  
  'location', 'Best' );
 
  %'Data (\mu \pm \sigma)' , ...
  %'Model (\it{C x^3})'    , ...  
  %'Fit (\it{C x^3})'      , ...
 
set( gca                       , ...
    'FontName'   , FontName );
set([hTitle, hXLabel, hYLabel], ...
    'FontName'   , FontName);
set([hLegend, gca]             , ...
    'FontSize'   , FontSize - 2);
set([hXLabel, hYLabel]  , ...
    'FontSize'   , FontSize    );
set( hTitle                    , ...
    'FontSize'   , FontSize    , ...
    'FontWeight' , 'bold'      );
 
set(gca, ...
  'Box'         , 'off'     , ...
  'TickDir'     , 'out'     , ...
  'TickLength'  , [.02 .02] , ...
  'XMinorTick'  , 'on'      , ...
  'YMinorTick'  , 'on'      , ...
  'YGrid'       , 'on'      , ...
  'XColor'      , [.0 .0 .0], ...
  'YColor'      , [.0 .0 .0], ...
  'YTick'       , -1:0.5:1, ...
  'LineWidth'   , 1.0         );
 
 
% print(gcf, '-r300', 'matlab_opengl.png', '-dpng');
% print(gcf, '-r300', 'matlab_opengl.pdf', '-dpdf');
% print(gcf, '-r300', 'matlab_opengl.eps', '-depsc');
% ghostscriptConvertTo('png', 'matlab_opengl.eps', 'matlab_opengl.eps.png')
 
% print(gcf, '-r300', 'matlab_painters.png', '-dpng');
% print(gcf, '-r300', 'matlab_painters.pdf', '-dpdf');
% print(gcf, '-r300', 'matlab_painters.eps', '-depsc');
% ghostscriptConvertTo('png', 'matlab_painters.eps', 'matlab_painters.eps.png')
% 
% savefig('savefig', 'pdf', 'png', 'eps', '-fonts'); 
% 
% export_fig('exportfig_painters.pdf', '-pdf', '-painters');
% export_fig('exportfig_painters.eps', '-eps', '-painters');
% export_fig('exportfig_painters.png', '-png', '-painters', '-r300');
% 
% export_fig('exportfig_opengl.png', '-png', '-opengl', '-r300');
% 
% plot2svg('plot2svg.svg', hfig);
 
% matlabfrag('matlabfrag.eps','handle',hfig) ;
% mlf2pdf(gcf,'matlabfrag');
 
% latexPackages = ['\renewcommand{\sfdefault}{pmy}\n \renewcommand{\rmdefault}{pmy}'];
% latexfigure(hfig,'latexfigure','eps',latexPackages);
% latexfigure(hfig,'latexfigure','png',latexPackages);
% latexfigure(hfig,'latexfigure','pdf',latexPackages);