How to edit plots?

75 views (last 30 days)
Farah Shahpoor
Farah Shahpoor on 10 Sep 2019
Commented: Farah Shahpoor on 17 Sep 2019
Hello dear community,
I want to edit my plots. But I dont know how to do it.
They need to look as this ones.
Can some one help me?69856909_10211552380444921_1501550189071040512_n.jpg
  2 Comments
Farah Shahpoor
Farah Shahpoor on 11 Sep 2019
Thaks for your advise.
I corrected the subplot.
Yes, exactly I want the circles and triangled. But I need to combine both diagramms.
I will send you my Code. I just need to change the rho parameter. Here rho (AR Parameter is 0.8)
%Hybrid NKM under commitment
%% Step 1 define the parameters
%same Parameters as from the script
%Parameters
gam_f = 0.5
gam_b =0.5
beta= 1
gam_x = 0.2
lambda = 0.5
phi = 0.5 % IS Parameter for interest rate
sig = 1 % IS Parameter for interest rate
AR_par = 0.8
%% Step 2
% System is: (w;v)(+1) = A*[w;v] + [ 1;0;0;0;0]*eps
A11= [AR_par 0 0;0 0 0; 0 0 0];
A12= [ 0 0; 1 0; 0 1];
A21 =[ 0 -gam_f/(beta^2*gam_b) 0; -1/(beta*gam_f) 0 -gam_b/gam_f]; %Klammern nicht vergessen
A22 =[ 1/(beta^2*gam_b) gam_x/(beta^2*lambda*gam_b); -gam_x/(beta*gam_f) 1/(beta*gam_f)];
A = [ [A11 A12] ; [A21 A22] ]
%% Step 3
% using the Schur Decomposition to solve the state equations
% solve the system
disp('Schur decomposition')
[Z, T] = schur(A, 'complex')
disp('reorder eigenvalues in increasing order along the principal diagonal')
[Z T] = ordschur(Z,T, 1:5)
if abs(sum(sum(Z*T*Z'-A))) > 0.0001 && sum(sum(Z'*Z-eye(lenght(Z)))) > 0.0001
disp('Error in Schur decomposition')
end
disp('check Blanchard-Kahn')
abs_diag_T = abs(diag(T))';
%% Calculating the solution time path for nu, x and pi using the following law of motion:
% z(+1) = E[z(+1)] + Z_11^-1 * [1;0;0] * eps
T_11 = T(1:3,1:3)
Z_11 = Z(1:3,1:3)
Z_21 = Z(4:5,1:3)
T=1000000;
z_solution= zeros(3,T); % zeros because we have variables in i with t-1
w_solution= zeros(3,T); % zeros because we have variables in i with t-1
w_solution(:,1)=[ 1; 0; 0]; %initial jump
z_solution(:,1)=inv(Z_11)* w_solution(: ,1);%initial jump
v_solution= zeros(2,T);
i_solution= zeros(1,T); % nominal interest rate: IS umgestellt nach der Variable i.Hier liegt anscheinend das Problem.
for t= 2:T
z_solution(:,t)= T_11* z_solution(: ,t-1 );
w_solution(:,t)= Z_11 * z_solution(:,t);
v_solution(:,t)= Z_21 *inv(Z_11)* w_solution(:,t);
end
for t= 1:T-1
i_solution(:,t) =((1- phi)*v_solution(1,t+1)+phi*w_solution(2,t)-w_solution(2,t+1))*sig+ v_solution(2,t+1); % Jump in 1 anstatt 2. umgestellte IS-Kurve.
end;
%% plots
t=0: 20;
w_solution = real(w_solution);
v_solution = real(v_solution);
i_solution = real(i_solution);
figure
subplot(2,2,1); hold on;
plot(t, w_solution(2,t+2), 'k-', 'LineWidth',2)
xlabel(' t '); ylabel (' x '); title(' Output gap ')
axis([0 20 -4 2])
set(gca,'XTickLabel',{'0','5','10','15','20'})
box on
subplot(2,2,2); hold on;
plot(t, w_solution(3,t+2), 'k-', 'LineWidth',2)
xlabel(' t '); ylabel(' \pi '); title('Inflation')
axis([0 20 -0.5 1.5])
set(gca,'XTickLabel',{'0','5','10','15','20'})
box on
subplot(2,2,3); hold on;
plot(t, i_solution(t+1),'k-','Linewidth',2)
xlabel('t'); ylabel('i'); title('Interest rate')
axis([0 20 -1 3])
set(gca,'XTickLabel',{'0','5','10','15','20'})
box on
subplot(2,2,4); hold on;
plot(t, w_solution(1,t+1),'k-','Linewidth',2)
xlabel('t'); ylabel('nu'); title('Shock')
legend('\rho = 0','\rho = 0.8')
box on
Farah Shahpoor
Farah Shahpoor on 11 Sep 2019
When I just plug '->' for rho 0.8 I get an error message.

Sign in to comment.

Answers (3)

David K.
David K. on 10 Sep 2019
Edited: David K. on 11 Sep 2019
Using your sample code, I do not see what the error is. However I made a few changes to the code that I believe make the output look as desired. Important changes:
AR_par = 0.8
Is changed to:
AR_par1 = [0.8 0];
figure
for n = 1:2
AR_par = AR_par1(n);
This allows the code to be run for both values. The end of the for loop is at the very end of the code and the figure that was at the start of the plotting was removed for that one.
Next:
lineStyle = {'k->', 'k-o'};
subplot(2,2,1); hold on;
plot(t, w_solution(2,t+2), lineStyle{n}, 'LineWidth',1)
This changes between the two line styles when plotting the runs. I also decreased the LineWidth because I thought it looked better this way.
This resulted in the following figure:
exampleOutput.png

Farah Shahpoor
Farah Shahpoor on 10 Sep 2019
Hello David,
Sorry you are right. I should give more details.
This is my code
%% plots
t=0: 20;
w_solution = real(w_solution);
v_solution = real(v_solution);
i_solution = real(i_solution);
figure
subplot(4,2,1); hold on;
plot(t, w_solution(2,t+2), 'k-', 'LineWidth',2)
xlabel(' t '); ylabel (' x '); title(' Output gap ')
axis([0 20 -4 2])
set(gca,'XTickLabel',{'0','5','10','15','20'})
box on
subplot(4,2,2); hold on;
plot(t, w_solution(3,t+2), 'k-', 'LineWidth',2)
xlabel(' t '); ylabel(' \pi '); title('Inflation')
axis([0 20 -0.5 1.5])
set(gca,'XTickLabel',{'0','5','10','15','20'})
box on
subplot(4,2,3); hold on;
plot(t, i_solution(t+1),'k-','Linewidth',2)
xlabel('t'); ylabel('i'); title('Interest rate')
axis([0 20 -1 3])
set(gca,'XTickLabel',{'0','5','10','15','20'})
box on
subplot(4,2,4); hold on;
plot(t, w_solution(1,t+1),'k-','Linewidth',2)
xlabel('t'); ylabel('nu'); title('Shock')
box on

Farah Shahpoor
Farah Shahpoor on 10 Sep 2019
The code is working without any problems but I want to change the layout of my plots as in the picture above
  1 Comment
David K.
David K. on 10 Sep 2019
First, you should add these as comments or edits to your original question not answers to your question.
Issue 1 is your subplot(4,2,x) is wrong, it should be subplot(2,2,x)
Next, since I do not have your data I cannot run it to easily see what you have. What is it that you want from the example layout?
If you want the circles and triangles as in the example those are shown in my original answer.

Sign in to comment.

Categories

Find more on Polar Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!