%% Saving and Loading Histogram2 Objects
% Use the savefig function to save a histogram2 figure.

y = histogram2(randn(100,1),randn(100,1));
savefig('histogram2.fig');
clear all
close all

%
% Use openfig to load the histogram figure back into MATLAB. openfig also returns a handle to the figure, h.

h = openfig('histogram2.fig');

%
% Use the findobj function to locate the correct object handle from the figure handle. This allows you to continue manipulating the original histogram object used to generate the figure.

y = findobj(h, 'type', 'histogram2')

% Copyright 2015 The MathWorks, Inc.