How to plot pie chart of different size on map?

7 vues (au cours des 30 derniers jours)
Jonathan Demmer
Jonathan Demmer le 10 Mar 2022
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]);

Réponses (1)

Abhaya
Abhaya le 3 Oct 2024
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.

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by