Make a pie chart map

11 views (last 30 days)
Trevor King
Trevor King on 27 Sep 2017
Commented: Patrick Anderson on 31 Aug 2021
The code below plots circles on a map, the size of which is proportional to the sum of 3 quantities (see attached image). I would like to make a map that has a pie-chart at each location for the relative portions of A, B & C ... and still have the size of the circle proportional to the sum of 3 quantities.
% PieChartMap_test.m
%%Create data.
Name = {'London', 'Edinburgh', 'Amsterdam', 'Paris', 'Rome'};
Lat = [51.508530, 55.953251, 52.379189, 48.864716, 41.890251];
Lon = [-0.076132, -3.188267, 4.899431, 2.349014, 12.492373];
A = [3,7,5,1,8];
B = [1,7,9,5,7];
C = [2,6,8,2,7];
Total = A + B + C;
%%Scale data so you can see circles on map.
maxCircleSize = 2000;
Total_forMapCircles = maxCircleSize * (Total/max(Total));
%%Make map with circle size proportional to Total.
load coastlines
LatLim = [min(Lat)-2 max(Lat)+2];
LonLim = [min(Lon)-2 max(Lon)+2];
worldmap(LatLim, LonLim)
coast = plotm(coastlat, coastlon);
scatterm(Lat,Lon,Total_forMapCircles,[0.5 0.5 0.5],'filled')

Answers (1)

Chad Greene
Chad Greene on 27 Sep 2017
Edward Tufte says the only thing worse than a pie chart is several of them. Also, by "size of the circle" do you mean its radius or area? The radius of a circle does not scale linearly with its area, so which represents the data? Further complicating things, humans do not perceive the size of a circle linearly with its radius or its area. With an uncertain transfer function between the "size of the circle" and the data it represents, you lose the quantitative nature of your data.
The idea of multiple pie charts of various size on a map makes me cringe for those reasons. Also it often feels like trying to pile in too much information in the same field of view, and the big picture most often gets lost because it's not natural or intuitive to understand how it all goes together. It tasks the viewer with meticulous work of trying to relate the size of a pink slice of pie over Hamburg to the blue slice over Venice. And then it's still not clear what exactly the size means, quantitatively. However, if you really want to go down this route, you might consider using pie with mfwdtran something like this:
X = [1 3 0.5 2.5 2];
p=pie(X);
p(1).Vertices
sc = 0.001; % <scaling factor (different for each city)
% Loop through each slice of the pie:
for k = 1:2:length(p)
% x,y coordinates of a slice:
tmp = p(k).Vertices;
% Scale the size of the slice:
tmp = tmp*sc;
[x0,y0] = mfwdtran(lat,lon); % <geocoordinates of the city
% Place the center of the pie on its city:
tmp(:,1) = tmp(:,1)+x0;
tmp(:,2) = tmp(:,2)+x0;
patch(tmp(:,1),tmp(:,2),'b') % <-specify the color you want
end
  1 Comment
Patrick Anderson
Patrick Anderson on 31 Aug 2021
"Edward Tufte says the only thing worse than a pie chart is several of them. "
I wanted to thank the author for a little bit of humor on the topic of visualizing quantitative information. The world needs more of that.
PLA

Sign in to comment.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!