Hi Adam,
I got some support on this topic. You can try the hidden/undocumented Behavior.linked.YDataSource property from HISTOGRAM handle.
figure;
%generate data in struct
data.energy = randn(1000,1);
data.pulse = randn(1000,1);
%scatter plot
subplot(1,2,1)
hS = plot(data.energy,data.pulse,'g.');
hS.XDataSource = 'data.energy';
hS.YDataSource = 'data.pulse';
%histogramming
subplot(1,2,2)
hH = histogram(data.energy);
hH.Behavior.linked.YDataSource = 'data.energy';
hLD = linkdata('on');
hB = brush;
hB.Enable= 'on';
dpm = datamanager.linkplotmanager;
cellfun(@(x)x.close, {dpm.Figures.Panel});
This is how you can set the datasource of a histogram programmatically. Plot shows annotation in the right histogram when you brush the left plot by using the combination of brushing and linkdata.
My challenge is now to integrate this functionality in a UI or app It is challenging because linking data works only for variables (data.energy etc) from the base workspace.
Patrick