Skip to content

Instantly share code, notes, and snippets.

@jcchurch
Created April 20, 2011 03:16
Show Gist options
  • Save jcchurch/930267 to your computer and use it in GitHub Desktop.
Save jcchurch/930267 to your computer and use it in GitHub Desktop.
Quickly plot graphs in Matlab
function quickPlot(varargin)
% This function is useful for printing point
% cloud data quickly. This function accepts
% one or more vectors, in either 2D or 3D,
% and either row-order or column-order format.
n = size(varargin, 2);
colors = char('r.', 'g.', 'b.', 'c.', 'm.');
num_colors = size(colors, 1);
figure;
for i = 1:n
a = varargin{i};
color = colors(mod(i-1,num_colors)+1,:);
if size(a, 1) == 2
plot(a(1,:), a(2,:), color);
elseif size(a, 2) == 2
plot(a(:,1), a(:,2), color);
end
if size(a, 1) == 3
plot3(a(1,:), a(2,:), a(3,:), color);
elseif size(a, 2) == 3
plot3(a(:,1), a(:,2), a(:,3), color);
end
hold on;
end
hold off;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment