Is it possible to explode/expand a map? i.e. separate the countries by a given distance (such as exploding a pie chart)
1 view (last 30 days)
Show older comments
I have this .shp file which represents the map of Italy, where each row represents a single region
I'm able to plot it using the built-in function mapshow, but now I'd like to explode the map, i.e. plot the same map but with all the regions separated by a given distance, let's say 5 pixels. Basically I'd like to obtain the same effect as when we explode a pie chart
Is this possible with the matlab functions or we should manually edit the X, Y coordinates of each region?
0 Comments
Answers (1)
Johan
on 4 Jul 2022
You could scale the regions around there geometric centers. There are builtin matlab tool using the polyshape structure that can do so relatively easily:
square = polyshape([0,1,1,0],[1,1,0,0]); % create a template square
%Translation matrix to create 4 contiguous regions
Translatation_matrix = [0,1,1,0;...
0,0,1,1];
%initialize data structure
data(1:length(Translatation_matrix)) = struct('shape',polyshape());
scaleddata = data;
%Translate template according to Translatation_matrix and fill results in
%data structure
for i_shape = 1:length(Translatation_matrix)
data(i_shape).shape = translate(square,Translatation_matrix(:,i_shape)');
end
figure(1)
plot([data.shape])
axis equal
% Using centroid and scale on the translated square, they now have a gap
% between each contiguous regions
for i_shape = 1:length(Translatation_matrix)
[X,Y] = centroid(data(i_shape).shape);
scaleddata(i_shape).shape = scale(data(i_shape).shape, 0.95,[X,Y]);
end
figure(2)
plot([scaleddata.shape])
axis equal
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!