How to plot two MATLAB polar plot in a single figure?

조회 수: 56 (최근 30일)
Kalyan Jyoti Kalita
Kalyan Jyoti Kalita 2020년 1월 18일
댓글: Star Strider 2020년 1월 20일
% 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.

답변 (1개)

Star Strider
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 —
1How to plot two MATLAB polar plot in a single figure - 2020 01 18.png
  댓글 수: 2
Kalyan Jyoti Kalita
Kalyan Jyoti Kalita 2020년 1월 20일
% Program for polar plot
clear;
syms sumwh sumwe rhooh rhooe
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
sumwh=0;
sumwe=0;
for i=1:input(1,1)
vh(i)=(d(i)-c(i)*(a(i)+b(i))*0.5)/(1-c(i)*c(i)); % Equation 10 of the JACS and PCCP paper
ve(i)=(s(i)-r(i)*(p(i)+b(i))*0.5)/(1-r(i)*r(i)); % Equation 10 of the JACS and PCCP paper
eh(i)=(y(i)-u(i)+v(i)-x(i))*27.2112; % Hole Reorganization Energy
ee(i)=(z(i)-m(i)+n(i)-x(i))*27.2112; % Electron Reorganization Energy
wh(i)=(vh(i)*vh(i)/6.5821192569654e-16)*((3.1415926/(eh(i)*0.026))^0.5)*exp(-eh(i)/(4*0.026));
we(i)=(ve(i)*ve(i)/6.5821192569654e-16)*((3.1415926/(ee(i)*0.026))^0.5)*exp(-ee(i)/(4*0.026));
sumwh=sumwh+wh(i);
sumwe=sumwe+we(i);
end
for i=1:input(1,1)
wih(i)=wh(i)^2/sumwh;
wie(i)=we(i)^2/sumwe;
end
for i=1:input(1,1)
uh(i)=wih(i)*r(i)^2*10^(-16)/(2*0.026); % Hole Mobility Values without the angles
ue(i)=wie(i)*r(i)^2*10^(-16)/(2*0.026); % Electron Mobility Values without the angles
end
theta=[0:0.02:2*pi];
rhooh=0;
rhooe=0;
for i=1:input(1,1)
rhoh=0;
rhoe=0;
rhoh=uh(i).*cos(sita(i)-theta).*cos(sita(i)-theta).*cos(gama(i)).*cos(gama(i));
rhooh=rhooh+rhoh;
rhoe=ue(i).*cos(sita(i)-theta).*cos(sita(i)-theta).*cos(gama(i)).*cos(gama(i));
rhooe=rhooe+rhoe;
end
figure(1);
Hole=max(rhooh)
Electron=max(rhooe)
polarplot(theta,rhooh,'k','LineWidth',2)
polarplot(rhooh,'-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
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
I have edited the code (shown above) but still not getting two polar plot in a single figure. Where I am wronG?
Star Strider
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 CenterFile Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by