ErinGoBragh
ErinGoBragh

Reputation: 336

Changing colormap for a polarplot in Matlab?

I'm trying to change the colormap of a polar plot in order to get more colors. The default matlab colormap doesn't have enough colors so it repeats and this gets confusing for viewers.

I wrote a simplified example of what I'm trying to do:

theta = linspace(0,6*pi);
rho1 = theta/10;
polarplot(theta,rho1)
hold on
for n = 1:15
    rho2 = theta/(12-n/5);
    polarplot(theta,rho2)
end
fig = gcf;
colormap(fig, hsv(16))
hold off

However when I run this I still get the same 7 default colormap colors. How do you force matlab to use a specific colormap?enter image description here

Upvotes: 0

Views: 642

Answers (1)

Prakhar
Prakhar

Reputation: 325

theta = linspace(0,6*pi);
rho1 = theta/10;
c = colormap(hsv(16));
polarplot(theta,rho1,'color',c(1,:))
hold on
for n = 1:15
    rho2 = theta/(12-n/5);
    polarplot(theta,rho2,'color',c(n+1,:))
end

Upvotes: 1

Related Questions