How to draw a sidebar in polar plotting?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Wiqas Ahmad
am 24 Dez. 2021
Kommentiert: Wiqas Ahmad
am 24 Dez. 2021
How can I draw a sidebar (red encircled) with a polar plot as shown in figure. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/842650/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/842650/image.png)
My program and figure are given below:
clc;
clear all;
close all;
%% ------------------------------Program-------------------------------------
N0=100;
r_med=[0.445 0.889 1.445 8];
sigma_g=7;
N_ang=91;
theta =0:(pi/180): (2*pi);
Num_r = 50e3;
r = linspace(1,50,Num_r)./2;
col=['k' 'b' 'r' 'g'];
for i=1:length(r_med)
[s1(i,:),s2(i,:),~,~,~,~]=bhmie(r_med(i),1.33,91)
cs1(i,:)=conj(s1(i,:));
cs2(i,:)=conj(s2(i,:));
ph_ft(i,:)=s1(i,:).*cs1(i,:)+s2(i,:).*cs2(i,:);
Rs1(i,:)=real(s1(i,:));
Rs2(i,:)=real(s2(i,:));
phf(i,:)=[ph_ft(i,:) fliplr(ph_ft(i,2:181))];
polarplot(theta,phf(i,:));
end
%% -------------------------------Title--------------------------------------
figure('name','Polar plot of scattering phase')
subplot(2,2,1,polaraxes);
hold on
polarplot(theta,phf(1,:),'color',col(1),'Linewidth',1.5);
title('\bf (a) Scattering phase function','FontSize',...
16,'FontWeight','normal')%\bf(bold font),\rm(normal font),\it(italian font)
legend('R_{e}=4\mum','location','south','FontSize',12);
legend boxoff
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','on','Fontname','Arial','Fontsmoothing','on');
%%
subplot(2,2,2,polaraxes);
hold on
polarplot(theta,phf(2,:),'color',col(2),'Linewidth',1.5);
title('\bf (b) Scattering phase function','FontSize',...
16,'FontWeight','normal')%\bf(bold font),\rm(normal font),\it(italian font)
legend('R_{e}=8\mum','location','south','FontSize',12);
legend boxoff
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','on','Fontname','Arial','Fontsmoothing','on');
%%
subplot(2,2,3,polaraxes);
hold on
polarplot(theta,phf(3,:),'color',col(3),'Linewidth',1.5);
title('\bf (c) Scattering phase function','FontSize',...
16,'FontWeight','normal')%\bf(bold font),\rm(normal font),\it(italian font)
legend('R_{e}=13\mum','location','south','FontSize',12);
legend boxoff
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','on','Fontname','Arial','Fontsmoothing','on');
%%
subplot(2,2,4,polaraxes);
hold on
polarplot(theta,phf(4,:),'color',col(4),'Linewidth',1.5);
title('\bf (d) Scattering phase function','FontSize',...
16,'FontWeight','normal')%\bf(bold font),\rm(normal font),\it(italian font)
legend('R_{e}=72\mum','location','south','FontSize',12);
legend boxoff
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','on','Fontname','Arial','Fontsmoothing','on');
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[.3 .05 .45 .75])
print(gcf,'Polar plot of scattering phase.tiff','-dtiff','-r300');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/842655/image.png)
2 Kommentare
Star Strider
am 24 Dez. 2021
What does the sidebar represent, what are the units, and does it have a specific relation to the polar plot?
Akzeptierte Antwort
Chunru
am 24 Dez. 2021
theta =0:(pi/180): (2*pi);
r = cos(theta)
ax=subplot(221);
polar(theta, r);
pos = ax.Position
pos(1) = pos(1)-0.05; % adjust pos to fit your need
ax1 = axes('Position', pos, 'Color', 'none');
ax1.XAxis.Visible = 'off'; % turn off x axis
ax1.YLim = [-2 2];
ax1.YLabel.String = "Phase Function sr^1";
ax1.YMinorTick = 'on';
ax1.TickDir = 'out';
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Polar Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!