MATLAB: How to print a biograph to a Handle Graphics figure programmatically in MATLAB 7.9 (R2009b)

Bioinformatics Toolbox

I want to print my biograph to a Handle Graphics figure from the command line. I can do this from the biograph window itself by selecting the File menu -> Print to Figure option.
My end goal is to export the biograph to a file.

Best Answer

The ability to print a biograph to a figure from the command line is not available in the Bioinformatics Toolbox 3.4 (R2009b).
As a workaround you can use the COPYOBJ function to copy the contents of axes in the biograph viewer to another figure and then print that figure. The code below is an illustration:
cm = [0 1 1 0 0;1 0 0 1 1;1 0 0 0 0;0 0 0 0 1;1 0 1 0 0];
bg = biograph(cm);
g = biograph.bggui(bg);
f = figure;
copyobj(g.biograph.hgAxes,f);
Alternatively, you can use the following code to find the handle to the figure containing the biograph object, and export the figure using the PRINT command:
f = get(g.biograph.hgAxes, 'Parent');
print(f, '-djpeg', 'test.jpg')
%You can also make the handle to the figure visible to PRINT and other functions by executing
set(f, 'HandleVisibility', 'on')