2d density map in non rectangular region

10 Ansichten (letzte 30 Tage)
Tiago
Tiago am 18 Nov. 2025
Beantwortet: Star Strider am 18 Nov. 2025
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');

Antworten (1)

Star Strider
Star Strider am 18 Nov. 2025
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')
.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by