2d density map in non rectangular region

9 次查看(过去 30 天)
Tiago
Tiago 2025-11-18,15:34
回答: Star Strider 2025-11-18,16:47
I want to make this graph but instead of discrete points i want it to be a smooth color gradient. How can i do this? Every solution i found so far works with meshgrid which is not so good for this geometry. Thanks!
Code to generate the graph in the picture:
data = load('data_Temperature_T.dat');
x = data(:,1);
y = data(:,2);
T = data(:,3);
figure;
scatter(x, y, 20, T, 'filled');
axis equal tight;
colorbar;
xlabel('x'); ylabel('y');
title('Temperature');

回答(1 个)

Star Strider
Star Strider 2025-11-18,16:47
It would help to have your data, since I cannot reproduce those curves here.
Try something like this --
n = 50;
a = linspace(pi, pi/2, n);
r = linspace(4, 20, n)*0.01;
x = [0.02*cos(a); r.*cos(a)].';
y = [0.05*sin(a); r.*sin(a)].';
figure
plot(x, y)
axis('equal')
c = [linspace(0, 0.5, n); linspace(0, 0.5, n)].';
figure
patch([x(:,1); flip(x(:,2))], [y(:,1); flip(y(:,2))], [c(:,1); flip(c(:,2))])
axis('equal')
.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by