Change Backgroundcolour of Plot
Show older comments
Hey I created a polarplot of a matrix with 3 colums so the polarplot has 3 "circles". I want to change the Background colour between the first and third "circle" to grey
1 Comment
KSSV
on 29 Oct 2021
Show us the code you tried.
Answers (1)
Try this for a start —
a = linspace(0, 2*pi, 200);
r = [1;2;3]*ones(size(a));
[A,R] = pol2cart(a.',r.');
radials = linspace(0, 2*pi, 13);
circs = [0; max(r(:,1))]*ones(size(radials));
[Arad,Rrad] = pol2cart(radials,circs); % Radials
[Acrc,Rcrc] = pol2cart(a,(0:0.5:max(r(:,1)))'*ones(size(a))); % Circles
figure
plot(A, R, 'LineWidth',2)
hold on
plot(Arad, Rrad, '-k')
plot(Acrc', Rcrc', '-k')
[X,Y] = pol2cart([a flip(a)], [r(1,:) flip(r(3,:))]);
patch(X, Y, [1 1 1]*0.25, 'FaceAlpha',0.2, 'EdgeColor','none')
hold off
axis('equal')
set(gca,'Visible','off')
d30 = deg2rad(30);
text(cos(d30)*Acrc(:,1), sin(d30)*Acrc(:,1), compose('%.1f',Acrc(:,1)), 'Horiz','center', 'Vert','top', 'Rotation',30)
text(Arad(2,1:end-1)*1.1, Rrad(2,1:end-1)*1.1, compose('%.0f°',rad2deg(radials(1:end-1))), 'Horiz','center', 'Vert','middle')
.
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!