Figured it out. Partially borrowed from: here
dat_bins=readtable("Bin_Input.xlsx");
%create RGB's for dat_bins
for j=1:length(dat_bins.bin_color)
if matches(string(dat_bins.bin_color(j)),"b")
dat_bins.rgb{j}=[0 0 1];
elseif matches(string(dat_bins.bin_color(j)),"g")
dat_bins.rgb{j}=[0 1 0];
elseif matches(string(dat_bins.bin_color(j)),"y")
dat_bins.rgb{j}=[1 1 0];
elseif matches(string(dat_bins.bin_color(j)),"o")
dat_bins.rgb{j}=[1 165/255 0];
else
dat_bins.rgb{j}=[1 0 0];
end
end
fig_leg=figure('Visible', 'on'); %create stand alone legend
axis off
for k=1:length(dat_bins.bin_start)
fig_leg=scatter(nan,nan, 'MarkerFaceColor', dat_bins.rgb{k});
hold on
end
legend(dat_bins.bin_name')
% legend window
set(gcf,'Position',[0,0,1024,1024]);
legend_handle = legend('Orientation','vertical');
% This sets the figure to have the same size as the legend
set(gcf,'Position',(get(legend_handle,'Position')...
.*[0, 0, 1, 1].*get(gcf,'Position')));
set(legend_handle,'Position',[0,0,1,1]);
% Put the figure back in the middle screen area
set(gcf, 'Position', get(gcf,'Position') + [500, 400, 0, 0]);