MATLAB: Determine if using HG2

r2014bgraphics

How can I determine if MATLAB or the current figure is using the new graphics pipeline, HG2? I need a function
tf = ishg2(figure_handle)
which should be backwards compatible, say to MATLAB 7.0, and also account for the fact that people can choose which rendering pipeline to use (HG1 or HG2) in newer MATLAB releases, so simply checking version number is not sufficient.

Best Answer

I've ended up using the undocumented function, graphicsversion():
function tf = ishg2(fig)
try
tf = ~graphicsversion(fig, 'handlegraphics');
catch
tf = false;
end