niceplot: Preparing Camera-Ready Plots in Matlab
[This post is recovered from my old site kaisare.net and posted here with minor modifications. Originally posted in October 2005.]
Here is a Matlab code for making camera-ready plots for presentations or papers. I found these values to be the optimum for journals that use two-column format. Save the figure as eps for use with LaTeX, or copy it and paste in a word file. If you do the latter, make sure that in Edit >> Copy Options >> Clipboard Format, the option “Preserve information (metafile if possible)” is selected.
This code is released under CC Attribution 2.5 license. You may use, modify, share or sell this code provided the second line (”Niket Kaisare, nkaisare [at] gmail.com”) is kept intact. I assume no liability for any problems the use of this code may cause.
% Niceplot: Make print-ready figures
% Niket Kaisare, nkaisare [at] gmail.com
%
% Usage:
% niceplot(x1, y1[, s1], [x2, y2[, s2], ...], ...
% xlabel, ylabel, title)
% Where:
% (x1, y1), (x2, y2), ..., are data to be plotted
% Optional: String (s1, s2, ...) to specify line styles
% Required: X axis label, Y axis label and Title
% Use blank [] if none exist
%
% Examples
% niceplot(a, b, '-bx', 'hour', 'rainfall (in)', [])
% niceplot(a, b, x, y, [], [], 'Brownian Motion')
function niceplot(varargin)n = nargin;
xl = varargin{n-2}; % X Label
yl = varargin{n-1}; % Y Label
tt = varargin{n}; % Axis Title
plot(varargin{1:n-3}); % Plotting Data
% Make lines thicker
lin = get(gca,’children’);
for i = 1:length(lin)
set(lin(i), ‘linewidth’, 2.0);
end
% Make nice title
if (tt)
set(gca,’position’, [0.13, 0.13, 0.83, 0.78]);
title(tt,’fontname’,’times’,’fontsize’, 20);
else
set(gca,’position’, [0.13, 0.13, 0.83, 0.8]);
end% Make nice axes labels
set(gca,’fontname’,’times’,’fontsize’, 20);
xlabel(xl,’fontname’,’times’,’fontsize’, 20);
ylabel(yl,’fontname’,’times’,’fontsize’, 20);