How to plot pie chart of different size on map?

6 次查看(过去 30 天)
Hi all,
The code below create a graph representing UK and Irleand (see attached file). I would like to add on this graph pie chart with different sizes at different places. can someone help me, please?
(I previously used m_map to add pie chart on graph using m_piechart however the coast line resolution was to coarse for my study)
Cheers
close all
clear all
clc
% assign the path to your working directory:
cd ('E:\publi\Waiting-room\Matt_paper_hydrogen\figure_Matt\new\gshhg-bin-2.3.7(1)\');
% add path to TelemacTolls functions (i.e. to read in telemac files into MATLAB):
addpath ('C:\Matlab_download\m_map1.4\m_map\');
workingFolder = tempdir;
latlim = [48 63];
lonlim = [-12 3];
S = gshhs('gshhs_h.b', latlim, lonlim);
levels = [S.Level];
L1 = S(levels == 1);
figure
plot ([L1.Lon],[L1.Lat], '-b');
xlim([-11 3]);
ylim([49 61]);

回答(1 个)

Abhaya
Abhaya 2024-10-3
Hi Jonathan,
In MATLAB, you can create multiple pie charts of different sizes using the MATLAB ‘axes and pie functions.
The Position property in MATLAB ‘axes’ function lets you define the size and location of each Cartesian axis. The value of the ‘Position’ property can be specified as a four-element vector [left bottom width height]. This allows you to precisely control where each pie chart appears in your figure.
Below is a simple example demonstrating how to display multiple pie charts within a single figure.
figure;
hold on; % Hold on to add pie charts later
% Define positions and sizes for the pie charts
positions = [0.2, 0.5; 0.5, 0.3; 0.6, 0.5];
sizes = [0.1, 0.15, 0.2]; % Relative sizes for each pie chart
% Data for the pie charts
data = {[1, 2, 3], [2, 3, 4], [3, 4, 5]};
% Add pie charts at specified positions and sizes
for i = 1:length(positions)
% Create a new set of axes for each pie chart
ax = axes('Position', [positions(i, 1), positions(i, 2), sizes(i), sizes(i)]);
pie(ax, data{i});
axis off; % Turn off the axis for pie charts
end
hold off;
For more information, please follow the given MATLAB documentations.
Hope this solves your query.

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by