On Thu, May 9, 2013 at 12:03 PM, Ignacio Diaz-Emparanza <ignacio.diaz-emparanza@ehu.es> wrote:
On 07/05/13 19:29, Allin Cottrell wrote:
This is partly in response to something Ignacio asked for a 
while ago, namely the ability to produce within a function 
package, plots that are usually only available via GUI means.
Thanks for your attention ;-))

What I have in CVS is just at the proof of concept stage, but 
here's the concept:

1) Parallel to certain commands, we offer a function that 
returns the information needed to produce a plot, in the form 
of a bundle. In this bundle we record the name of the built-in 
function that produced it.

2) We provide a built-in function (or maybe eventually a 
command) that produces a plot from such a bundle: it checks 
for the creator of the bundle and hands off to the appropriate 
specialized plotting function.

Right now this is (partially) implemented for the irf() 
function. Until now this function has returned a matrix, but 
in CVS it returns a bundle which contains the matrix along 
with the additional info needed for the plot (e.g. the names 
of the target and shock variables and the "alpha" for the 
confidence interval, if any).

Isn't this backward incompatible? Actually, no. You can still 
assign from the irf() function to a matrix. That's because 
I've added a special bundle key: if you add a matrix to a 
bundle under the name "payload_matrix", then the following 
sort of thing (a "cast" from bundle to matrix) will work:

bundle b
b["payload_matrix"] = I(3)
b["otherthing"] = "hello"
matrix m = b

Here's an example of the whole deal:

open data9-7
# assign from irf() to bundle
bundle b = irf(1, 2, 0.2)
bplot(b, "display")
# we can still assign from irf() to matrix
matrix m = irf(1, 2, 0.2)

Umm...  I am not sure I am understanding all this subject.
The idea is that bplot() is the function/command which takes out the plot, right?
(I am not seeing now it does anything)
Can it run from a function?

Hmm, true enough, it doesn't show anything in the GUI program.
I was trying with gretlcli, where it worked OK.

I think "bplot" really has to be a converted into a command
for this to work in the GUI. I'll pursue that when I get a