Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. function MakeFigureLatexReady(figureName,gridOn)
  2. % The purpose of this function is standardize MATLAB figures
  3. % so they look neat and uniform for latex documents
  4.  
  5. % Operation: provide a .fig file in the local folder.
  6. % If it is in a different directory edit the dir value below.
  7. % The function will produce a .eps file with the same name as
  8. % the original .fig file in the same directory. You can also
  9. % change grid to 'off' to disable grids on figures
  10.  
  11. % example: MakeFigureLatexReady('baseline_occupancy_vs_collisions.fig')
  12. grid = 'on';
  13. if nargin>1
  14. if ~gridOn
  15. grid = 'off';
  16. end
  17. end
  18. dir = '';
  19.  
  20. %%%%%%%%%%%%%%%%%%%
  21. fig = openfig(figureName);
  22. set(fig,'WindowStyle','normal'); %Undock
  23. % Figure Size
  24. defaultSize = [570 422];
  25. fig.Position(3:4) = defaultSize;
  26. % Font Sizes and Types
  27. if length(fig.Children)>1
  28. index = 2;%has a legend
  29. else
  30. index = 1;%no legend
  31. end
  32. fig.Children(index).FontSize = 10;
  33. fig.Children(index).XLabel.FontSize = 12;
  34. fig.Children(index).YLabel.FontSize = 12;
  35. fig.Children(index).XLabel.FontName = 'Arial';
  36. fig.Children(index).YLabel.FontName = 'Arial'; %'Helvetica'
  37. % Remove Title
  38. fig.Children(index).Title.String = '';
  39. % Grid
  40. fig.Children(index).XGrid = grid;
  41. fig.Children(index).YGrid = grid;
  42. % Remove white borders
  43. fig.CurrentAxes.LooseInset = fig.CurrentAxes.TightInset;
  44. %fig.PaperPositionMode = 'auto';% Ensure that the size of the saved figure is equal to the size of the figure on the display.
  45. %fig_pos = fig.PaperPosition;
  46. %fig.PaperSize = [fig_pos(3) fig_pos(4)]; % Set the page size equal to the figure size to ensure that there is no extra whitespace.
  47. % Save to eps
  48. filename = [figureName(1:end-3),'eps'];
  49. print(fig,[dir,filename],'-depsc','-loose','-tiff');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement