How to plot two MATLAB polar plot in a single figure?
71 次查看(过去 30 天)
显示 更早的评论
% Program for polar plot
clear;
syms sumw rhoo
load input.txt;
a=input(2,:); % Hole site energy (ea)/no need to put effective one
b=input(3,:); % Hole site energy (eb)/no need to put effective one
c=input(4,:); % Hole spatial overlap
d=input(5,:); % Hole charge transfer integral
p=input(6,:); % Electron site energy (ea)/no need to put effective one
q=input(7,:); % Electron site energy (eb)/no need to put effective one
r=input(8,:); % Electron spatial overlap
s=input(9,:); % Electron charge transfer integral
x=input(10,:); % Neutral Optimized energy
y=input(11,:); % CSP energy
z=input(12,:); % ASP energy
u=input(13,:); % Cationic optimized energy
v=input(14,:); % NSP with cationic geometry
m=input(15,:); % Anionic optimized energy
n=input(16,:); % NSP with anionic geometry
r=input(17,:); % Centroid to centroid distance
sita=input(18,:)*3.1415926/180; % Angle between the dimer vector and the refernce axis
gama=input(19,:)*3.1415926/180; % Angle between the dimer vector and the refernce plane
sumw=0;
for i=1:input(1,1)
v(i)=(d(i)-c(i)*(a(i)+b(i))*0.5)/(1-c(i)*c(i)); % Equation 10 of the JACS and PCCP paper
eh(i)=(y(i)-u(i)+v(i)-x(i))*27.2112; % Hole Reorganization Energy
w(i)=(v(i)*v(i)/6.5821192569654e-16)*((3.1415926/(eh(i)*0.026))^0.5)*exp(-eh(i)/(4*0.026)); % Rate of electron transfer Mercus Theory
sumw=sumw+w(i);
end
for i=1:input(1,1)
wip(i)=w(i)^2/sumw;
end
for i=1:input(1,1)
u(i)=wip(i)*r(i)^2*10^(-16)/(2*0.026); % Mobility Values without the angles
end
theta=[0:0.02:2*pi];
rhoo=0;
for i=1:input(1,1)
rho=0;
rho=u(i).*cos(sita(i)-theta).*cos(sita(i)-theta).*cos(gama(i)).*cos(gama(i));
rhoo=rhoo+rho;
end
figure(1);
Mobility=max(rhoo)
polarplot(theta,rhoo,'k','LineWidth',2)
polarplot(rhoo,'-o')
pax = gca
pax.FontSize = 14;
pax.ThetaColor = 'k';
pax.RColor = 'k';
pax.GridColor = 'k';
pax.LineWidth = 2;
pax.GridWidth = 5;
pax.ZeroAngleLine = '1';
pax.TitleTopFontSizeMultiplier='1'
pax.GridOverData='1'
pax.GridForeGroundColor='k'
hold on
sumw=0;
for i=1:input(1,1)
v(i)=(s(i)-r(i)*(p(i)+b(i))*0.5)/(1-r(i)*r(i)); % Equation 10 of the JACS and PCCP paper
ee(i)=(z(i)-m(i)+n(i)-x(i))*27.2112; % Electron Reorganization Energy
w(i)=(v(i)*v(i)/6.5821192569654e-16)*((3.1415926/(ee(i)*0.026))^0.5)*exp(-ee(i)/(4*0.026)); % Rate of electron transfer Mercus Theory
sumw=sumw+w(i);
end
for i=1:input(1,1)
wip(i)=w(i)^2/sumw;
end
for i=1:input(1,1)
u(i)=wip(i)*r(i)^2*10^(-16)/(2*0.026); % Mobility Values without the angles
end
theta=[0:0.02:2*pi];
rhoo=0;
for i=1:input(1,1)
rho=0;
rho=u(i).*cos(sita(i)-theta).*cos(sita(i)-theta).*cos(gama(i)).*cos(gama(i));
rhoo=rhoo+rho;
end
figure(1);
Mobility=max(rhoo)
polarplot(theta,rhoo,'k','LineWidth',2)
polarplot(rhoo,'-o')
title('Mobility of 25TR(R)');
pax = gca
pax.FontSize = 14;
pax.ThetaColor = 'k';
pax.RColor = 'k';
pax.GridColor = 'k';
pax.LineWidth = 2;
pax.GridWidth = 5;
pax.ZeroAngleLine = '1';
pax.TitleTopFontSizeMultiplier='1'
pax.GridOverData='1'
pax.GridForeGroundColor='k'
I want to plot two polar plot together in a single figure. I used the above code to do the same, but not sucessfull. I can plot them in two separate figure. I have attached the plot generated separately and input.txt file.
0 个评论
回答(1 个)
Star Strider
2020-1-18
编辑:Star Strider
2020-1-18
The hold calls must go after the appropriate figure call, not before it.
Example—
a = linspace(0, 2*pi);
r1 = abs(cos(a));
r2 = abs(sin(a));
figure
polarplot(a, r1)
hold on
polarplot(a, r2)
hold off
EDIT — (18 Jan 2020 at 15:41)
Added plot figure produced with my code —
2 个评论
Star Strider
2020-1-20
The problem is that your are asking polarplot to do weveral things it does not have the ability to do, and that was stopping the code and throwing errors.
Try this:
figure(1);
Hole=max(rhooh)
Electron=max(rhooe)
polarplot(theta,rhooh,'k','LineWidth',2)
% polarplot(rhooh,'-o') % <— MOVE THIS TO AFTER ‘hold on’
pax = gca;
pax.FontSize = 14;
pax.ThetaColor = 'k';
pax.RColor = 'k';
pax.GridColor = 'k';
pax.LineWidth = 2;
% pax.GridWidth = 5;
% pax.ZeroAngleLine = '1';
% pax.TitleTopFontSizeMultiplier='1'
% pax.GridOverData='1'
% pax.GridForeGroundColor='k'
hold on
polarplot(rhooh,'-o')
polarplot(theta,rhooe,'k','LineWidth',2)
polarplot(rhooe,'-o')
pax = gca
pax.FontSize = 14;
pax.ThetaColor = 'k';
pax.RColor = 'k';
pax.GridColor = 'k';
pax.LineWidth = 2;
% pax.GridWidth = 5;
% pax.ZeroAngleLine = '1';
% pax.TitleTopFontSizeMultiplier='1'
% pax.GridOverData='1'
% pax.GridForeGroundColor='k'
hold off
Delete the commented-out lines.
See the documentation on: PolarAxes Properties for a list of the properties that actually exist, and that it is possible to change.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!