MATLAB Answers

How to edit plots?

52 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
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
  1 Comment
Farah Shahpoor
Farah Shahpoor on 17 Sep 2019
Thanks a lot!!

Sign in to comment.


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.

Tags

Community Treasure Hunt

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

Start Hunting!