x = linspace(1,10,12);
y = linspace(0,1,12);
z = linspace(-4,0,12);
names = ['a';'b';'c';'a';'b';'a';'b';'a';'b';'c';'a';'b'];
years = [1990,1990,1990,1992,1992,1995,1995,2000,2000,2000,2005,2005];
for i = 1:length(x)
struct(i).x= x(i);
struct(i).y= y(i);
struct(i).z= z(i);
struct(i).name = names(i);
struct(i).year = years(i);
end
uyrs = unique([struct.year]);
sz = linspace(10,35,length(uyrs));
for i=1:length(uyrs)
szplot(i).year = uyrs(i);
szplot(i).sz = sz(i);
end
uname = unique({struct.name});
cols = ['#8c510a';'#fc8d59';'#d8b365'];
for i=1:length(uname)
cplot(i).name = uname{i};
cplot(i).color = cols(i,:);
end
n=1;
figure; tiledlayout(1,2);
for ind=1:length(struct)
nexttile(1)
hold on;
if strcmp(struct(ind).name,'a')
cc = cplot(matches({cplot.name},struct(ind).name)).color;
size = szplot(n).sz;
year = szplot(n).year;
p1(n) = scatter(struct(ind).x,struct(ind).y,size,'MarkerFaceColor',cc,'DisplayName',num2str(year));
n=n+1;
end
cc = cplot(matches({cplot.name},struct(ind).name)).color;
size = szplot([szplot.year]==struct(ind).year).sz;
scatter(struct(ind).x,struct(ind).y,size,'MarkerFaceColor',cc);
nexttile(2)
hold on;
scatter(struct(ind).z,struct(ind).y,size,'MarkerFaceColor',cc);
drawnow;
if ind==length(struct)
[lg1,obj]=legend(p1,'Orientation','Horizontal');
end
end
objhl = findobj(obj, 'type', 'patch');
for i = 1:length(objhl)
set(objhl(i), 'Markersize', sqrt(szplot(i).sz));
end
lg1.Layout.Tile = 'North';