# Plotting multiple IRFs - many endogenous vars

**URL:** <https://forum.dynare.org/t/plotting-multiple-irfs-many-endogenous-vars/17510>\
**Category:** Stochastic simulations\
**Created:** [17 February 2021 02:43 UTC](https://forum.dynare.org/t/plotting-multiple-irfs-many-endogenous-vars/17510 "2021-02-17T02:43:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![m6882](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@m6882](https://forum.dynare.org/u/m6882)\
**Post date:** [17 February 2021 02:43 UTC](https://forum.dynare.org/t/plotting-multiple-irfs-many-endogenous-vars/17510/1 "2021-02-17T02:43:11Z")

</div>

Hello,

I understand that if I want to plot multiple IRFs, I would need to do this on MATLAB. I have generated the code for my model and generated code for my variables from steady state (because I had about 52 endogenous variables but only needed 12 for analysis). I therefore have the following code for them after stoch\_simul as plots from deviations from steady state, for example for one variable I have:

```auto
yepos = strmatch('ye',M_.endo_names,'exact');

set(0,'DefaultAxesTitleFontWeight','normal');

figure('Name','Baseline impulse responses to copper price shock');

subplot(3,4,1);

plot(ye_e/oo_.dr.ys(yepos),'b-','LineWidth',2);

axis tight;

title('Tradeable sector output');

```

I wanted to please find out if I would be able to transfer these plots onto MATLAB to plot multiple IRFs and if there is any code that would help me with this as I am struggling

Thank you!

---

<div class="post-metadata">

**Author:** ![DoubleBass](https://forum.dynare.org/user_avatar/forum.dynare.org/doublebass/32/17420_2.png) [@DoubleBass](https://forum.dynare.org/u/DoubleBass)\
**Post date:** [17 February 2021 08:16 UTC](https://forum.dynare.org/t/plotting-multiple-irfs-many-endogenous-vars/17510/2 "2021-02-17T08:16:49Z")

</div>

Hi m6882,

see my answer to a [smiliar question](https://forum.dynare.org/t/subplot-construction/17479) a couple of days ago.  
If you only want to plot 12 endogenous variables, the easy way is just to incorporate those in the stoch\_simul command and not the others. Something like:` stoch_simul()1 2 ... 12`

Best

---

<div class="post-metadata">

**Author:** ![m6882](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@m6882](https://forum.dynare.org/u/m6882)\
**Post date:** [18 February 2021 21:06 UTC](https://forum.dynare.org/t/plotting-multiple-irfs-many-endogenous-vars/17510/3 "2021-02-18T21:06:14Z")

</div>

Thank you so much! Using this code I was able to do subplots:

```auto
dynare a.mod;
irf1 = oo_.irfs;
save a.mat irf1;

dynare b.mod;
irf2 = oo_.irfs;
save b.mat irf2;
load('a.mat','irf1');
load('b.mat','irf2');

ending_cell={'_e'};
%'y', 'dp', 'cs', 'cb', 'h', 'hs', 'r', 'qh', 'qz'
for ii=1:length(ending_cell)
    HOR=1:options_.irf;
    var={'y', 'dp', 'cs', 'cb', 'h', 'hs', 'r', 'qh', 'qz'};
    figure
    for jj=1:length(var)
        subplot(3,4,jj)
        eval(['irf1.' var{1,jj},ending_cell{1,ii}]);
        eval(['irf2.' var{1,jj},ending_cell{1,ii}]);
        hold on
        plot(HOR,[eval(['irf1.' var{1,jj},ending_cell{1,ii}])],'-b',HOR,[eval(['irf2.' var{1,jj},ending_cell{1,ii}])],'--r','LineWidth',2) ;
        title([var{1,jj}] )
    end
end

```

I wanted to find out on a few things:

1. is there any way I could compute deviations from steady state?
2. how can I change my labels automatically (i.e. is there any additional code I can use for this)?
3. is there any code I could use to label my x and y axes systematically?
4. I wanted to have boxes/lines within the IRFs, just o be neat - is there any way I could do this?

Thank you

---

<div class="post-metadata">

**Author:** ![DoubleBass](https://forum.dynare.org/user_avatar/forum.dynare.org/doublebass/32/17420_2.png) [@DoubleBass](https://forum.dynare.org/u/DoubleBass)\
**Post date:** [19 February 2021 13:41 UTC](https://forum.dynare.org/t/plotting-multiple-irfs-many-endogenous-vars/17510/4 "2021-02-19T13:41:06Z")

</div>

Glad it helped.  
Ad 1: Depends on what kind of model you have, if it is log-linearized it already shows percentage deviations from steady state for instance.  
Ad 2 - 4: Those questions are Matlab related so I would suggest you google exactly how you want your plots to look like and you will most certainly find what you are looking for.
