Save Plots Example

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PlotSaveEx.m 
% Written by Ebenezer P Gnanamanickam 
% Dec 2006.
% DISCLAIMER - I do not claim to be an expert on MATLAB but what little I
% have learned during the course of grad school here at Purdue University
% I want to share. If it's useful GREAT if not sorry.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% 
% This function (NOTE - This is a function in MATLAB because I am calling another
% function from within it) gives you an idea of how to make your plots look
% pretty and then auto save it wherever you choose. At the time of thesis
% writting when your advisor wants you to maodify your plots at the 11th
% hour and do 20 things while you are at it, this will make you life easier.
% All you need to do is change a few variables and then hit F5 and it will
% regenerate the plots and save it where you want in the format you want it
% to be saved. Again this becomes useful when you have similar data sets
% like data from different runs at different conditions. Instead of
% doing them one by one you can just write a script to load up your data
% (use the load command here and everything can be automated). YES !!!
% Geeky I know but believe me it saves you a hell of a lot of time. This is
% some data that I  don't even remember what its from but I just used it to show
% you what can be done. Again there is more than this... explore and bring
% out the inner geek in you. ENJOY!!!!!
%
% A note on the file formats to save as. For things you will print out
% after extensive study (I am not kidding a buddy and me as a means of
% procastination actually carried this study out by saving a fig as different
% formats and then printing them out) such as a thesis or report (esp for Latex
% users) use the eps format the command is 
% print -depsc -tiff full_file_path 
% if you want to save in the current directory you can skip the full file path. 
% The -tiff also gives you a tiff preview. Sometimes you 
% cannot see epsc on your screen using a normal image viewer this fixes that.
%
% However, again after extensive study we discovered that eps really really
% sucks for power point presentations. For this use the png format. The
% command is 
% print -dpng full_file_path
% if you do not want to save two differnet file versions use jpeg or
% bitmap. These are not great for either but its good enough for both.
% Again use the info as it pleases you.
% NOTE I HAVE COMMENTED OUT THE PRINT LINE YOU WILL NEED TO UNCOMMENT IT TO
% BE ABLE TO SAVE THE GENERATED PLOT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function []=PlotSaveEx()

clc; % clears the command window
clear all; % clears all the variables
close all; % close all exsisting windows

font='Arial'; % the font type on the plot
line_wdth=3;% the line width of grid on the plot
font_sz=18; % font size
font_wt='bold'; % font style

[Sheet1]=Data;


d1=Sheet1(:,1);
t1=Sheet1(:,2);
d2=Sheet1(:,3);
t2=Sheet1(:,4);


figure
h5=axes;
h1=plot(d1,t1,'r',d2,t2,'b');
h2=xlabel('Distance from cutting edge in \mu m');
h3=ylabel('Oil thickness in \mu m');
h4=legend('Test run #1','Test run #2',2);
set(h5,'FontName',font,'FontSize',font_sz,'FontWeight',font_wt)
grid;
axis([0 700 0 27])
set(h1,'LineWidth',line_wdth)
set(h2,'FontName',font,'FontSize',font_sz,'FontWeight',font_wt)
set(h3,'FontName',font,'FontSize',font_sz,'FontWeight',font_wt)
set(h4,'FontName',font,'FontSize',font_sz,'FontWeight',font_wt)
% print -djpeg100 filmtthick.jpg


function [Sheet1]=Data

Sheet1=[
   11.1110    2.7766   11.1110    1.1669
   22.2220    2.9118   22.2220    1.3604
   33.3330    3.2613   33.3330    1.5103
   44.4440    3.2600   44.4440    1.5662
   55.5550    3.3938   55.5550    1.7517
   66.6660    3.6102   66.6660    1.8761
   77.7770    3.8676   77.7770    2.1091
   88.8880    3.9393   88.8880    2.2870
   99.9990    4.2308   99.9990    2.4083
  111.1100    4.5919  111.1100    2.5502
  122.2210    4.9128  122.2210    2.8910
  133.3320    5.1834  133.3320    3.1244
  144.4430    5.3465  144.4430    3.4148
  155.5540    5.7977  155.5540    3.5822
  166.6650    6.0357  166.6650    3.8141
  177.7760    6.3162  177.7760    4.0929
  188.8870    6.5721  188.8870    4.2295
  199.9980    6.9668  199.9980    4.5432
  211.1090    7.2639  211.1090    4.8229
  222.2200    7.7493  222.2200    5.2219
  233.3310    7.9532  233.3310    5.4636
  244.4420    8.1180  244.4420    5.8776
  255.5530    8.4685  255.5530    6.2082
  266.6640    8.8800  266.6640    6.5687
  277.7750    9.5326  277.7750    6.9784
  288.8860    9.8784  288.8860    7.2607
  299.9970   10.2609  299.9970    7.5411
  311.1080   10.5983  311.1080    7.7512
  322.2190   10.8052  322.2190    8.1621
  333.3300   11.2820  333.3300    8.6171
  344.4410   11.4532  344.4410    8.7545
  355.5520   11.8887  355.5520    9.0856
  366.6630   12.4365  366.6630    9.5700
  377.7740   12.9566  377.7740    9.8503
  388.8850   13.3376  388.8850   10.0705
  399.9960   13.7043  399.9960   10.2946
  411.1070   14.2325  411.1070   10.8539
  422.2180   14.6690  422.2180   11.2545
  433.3290   14.9624  433.3290   11.4256
  444.4400   15.5236  444.4400   11.7794
  455.5510   15.7966  455.5510   12.2518
  466.6620   16.2597  466.6620   12.6715
  477.7730   16.9087  477.7730   12.9846
  488.8840   17.5536  488.8840   13.2654
  499.9950   18.2221  499.9950   13.8472
  511.1060   18.6248  511.1060   14.2339
  522.2170   19.2458  522.2170   14.5440
  533.3280   19.7089  533.3280   15.1166
  544.4390   20.2407  544.4390   15.5494
  555.5500   20.7491  555.5500   16.0942
  566.6610   21.2427  566.6610   16.8780
  577.7720   21.6947  577.7720   17.5317
  588.8830   22.1460  588.8830   17.8276
  599.9940   22.9023  599.9940   18.3241
  611.1050   23.5705  611.1050   18.9747
  622.2160   24.2415  622.2160   19.5424
  633.3270   24.9050  633.3270   20.0627
  644.4380   25.6231  644.4380   20.5556
  655.5490   26.5761  655.5490   21.1530
  666.6600   27.1990  666.6600   21.7010];

return;