%% Add a Bubble Legend
% Define a data set that shows the contamination levels of a certain toxin across different towns in a metropolitan area.
% Define towns as the populations of the towns.
% Define nsites as the number of industrial sites in the corresponding towns.
% Define nregulated as the number of industrial sites that conform to the local environmental regulations.
% Define levels as the contamination levels in the towns.

towns = randi([25000 500000],[1 30]);
nsites = randi(10,1,30);
nregulated = (-3 * nsites) + (5 * randn(1,30) + 20);
levels = (3 * nsites) + (7 * randn(1,30) + 20);

%
% Display the data in a bubble chart. Create axis labels using the xlabel, ylabel, and zlabel functions. Use the bubblesize function to make all the bubbles between 5 and 30 points in diameter. Then add a bubble legend that shows the relationship between bubble size and population.

bubblechart3(nsites,nregulated,levels,towns)
xlabel('Industrial Sites')
ylabel('Regulated Sites')
zlabel('Contamination Level')

bubblesize([5 30])
bubblelegend('Town Population','Location','eastoutside')

% Copyright 2020 The MathWorks, Inc.