Dear all,
Alternatively from the option of using oxdraw with the PL_FILLBOX symbol
and a DrawSymbol command, in GnuDraw some other options are available.
E.g.
http://www.tinbergen.nl/~cbos/packages/gnudraw/doc/gnudraw_tips.html#Fill
explains some options to fill a region using GnuDraw/GnuPlot.
For NBER-type data, this could be used rather easily. See attachment
which would generate shaded-region plot on fake data, in both a
quick-but-simple and elaborate way.
Greetings,
Charles Bos
/*
** NBER
**
** Purpose:
** Check how NBER data could be plotted
**
** Author:
** Charles Bos/James Davidson
**
** Date:
** 24/4/07
*/
#include <oxstd.h>
#include <arma.h>
#include <packages/gnudraw/gnudraw.h>
main()
{
decl iT, vTime, vY, vNBER, vSel, iMin, iMax, i;
iT= 50;
vTime= range(0, iT) + dayofcalendar(2007, 1, 1);
vY= armagen(zeros(iT, 1), rann(iT, 1), .95, 1, 0)';
iMin= floor(min(vY));
iMax= ceil(max(vY));
vNBER = vY .> 0;
// For simplicity, end in recession; there are T+1 x's
vNBER~= 0;
// Shade regions where NBER is 1; use closed curves.
// Shade between max(vY) and min(vY)
DrawTMatrix(0, vNBER .? iMax .: iMin, "", vTime, 0, 5);
// Alternatively, shade between vY and minimum, only below the curve
// DrawTMatrix(0, vNBER .? vY .: iMin, "", vTime, 0, 5);
DrawAdjust(ADJ_COLOR, 14, TP_USER, "filledcurves closed");
// Plot y-series afterwards, on top of the filled boxes
DrawTMatrix(0, vY, "y", vTime, 0, 0);
// To get the bounds of the regions running vertical, use a loop
// Find starting dates of booms and busts
vSel= vecrindex(vNBER .!= lag0(vNBER', 1)');
for (i= 0; i < sizerc(vSel)-1; i+= 2)
{
DrawTMatrix(1, iMin~iMax~iMax~iMin, "", vTime[vSel[i]]~vTime[vSel[i]]~vTime[vSel[i+1]-1]~vTime[vSel[i+1]-1], 0, 0);
DrawAdjust(ADJ_COLOR, 14, TP_USER, "filledcurves closed");
}
DrawTMatrix(1, vY, "y", vTime, 0, 0);
ShowDrawWindow();
}
|