%% 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 population of each town. Define nsites as the number of industrial sites in the corresponding towns. Define levels as the contamination levels in the towns. Then display the data in a bubble chart with axis labels. Call the bubblesize function to decrease the bubble sizes, and add a bubble legend that shows the relationship between the bubble size and population.

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

% Display bubble chart with axis labels and legend
bubblechart(nsites,levels,towns)
xlabel('Number of Industrial Sites')
ylabel('Contamination Level')
bubblesize([5 30])
bubblelegend('Town Population','Location','eastoutside')

% Copyright 2020 The MathWorks, Inc.