%% Display Two Sets of Data with Separate Colorbars
% Since R2020b
% An axes object can accommodate only one colorbar. To create a visualization with multiple colorbars, stack multiple axes objects in a tiled chart layout. Make only one of the axes visible, but display a colorbar next to each of them in an outer tile of the layout.
% Create the coordinate vectors, size data, and color data for two bubble charts.

x = 1:15;
n = 70 * randn(1,15) + 50;
y1 = n + x.^2; 
y2 = n - linspace(1,225,15);
sz1 = rand(1,15);
sz2 = rand(1,15);
c = linspace(1,10,15);

%
% Stack two axes objects, each containing a bubble chart, in a tiled chart layout.
% Create a 1-by-1 tiled chart layout t.
% Create axes object ax1 and a bubble chart with the winter colormap.
% Create axes object ax2 and a bubble chart with the autumn colormap. Make this axes object invisible by setting the Visible property to 'off'.
% Link the axes objects to keep them in sync. In this case, you can pass the children of t to the linkaxes function. Alternatively, you can pass a vector of individual axes objects to the function.

% create first bubble chart with winter colormap
t = tiledlayout(1,1);
ax1 = axes(t); 
bubblechart(ax1,x,y1,sz1,c)
colormap(ax1,'winter')

% create second bubble chart with autumn colormap
ax2 = axes(t);
bubblechart(ax2,x,y2,sz2,c)
colormap(ax2,'autumn')
ax2.Visible = 'off';

% link the limits of axes
linkaxes(t.Children)

%
% Display a colorbar with a label for each axes object in the east tile of the layout. The layout arranges the colorbars and keeps them aligned.

cb1 = colorbar(ax1);
cb1.Layout.Tile = 'east';
cb1.Label.String = 'Time (s)';

cb2 = colorbar(ax2);
cb2.Layout.Tile = 'east';
cb2.Label.String = 'Concentration (M)';

% Copyright 2020 The MathWorks, Inc.