Create a 2D plot with irregular axes

조회 수: 4 (최근 30일)
Sam Hurrell
Sam Hurrell 2025년 5월 2일
댓글: Sam Hurrell 2025년 5월 6일
I have a dataset with associated x and y coordinates, but the coordinates for both axes are not at regular intervals. Is there a way to make a map (ideally 2D but I would accept 3D) that shows these results - the values represented by colour - at their coordinates (akin to imagsc)?

답변 (2개)

Star Strider
Star Strider 2025년 5월 2일
The plot function does not care if the data are not regularly sampled. It wil plot them appropriately regardless.
Example —
t = sort(rand(1,100));
s = sin(5*pi*t);
figure
plot(t, s, '.-')
grid
axis('padded')
sp = s;
sp(end) = NaN;
c = sp;
figure
patch(t,s,c, EdgeColor='interp',Marker='s',MarkerFaceColor='flat')
grid
axis('padded')
colormap(turbo)
I am not certain what you want.
.
  댓글 수: 3
Star Strider
Star Strider 2025년 5월 5일
I am not certain what the image is, or what it represents.
A histogram2 plot could work.
Try something like this —
imshow(imread('TT3.png'))
x = randn(1000,1);
y = randn(1000,1);
figure
histogram2(x, y, 50, FaceColor='flat')
colormap(turbo)
% axis('equal')
axis('square')
view(0,90)
Make appropriate changes to get the result you want.
.
Sam Hurrell
Sam Hurrell 2025년 5월 6일
The attached image is a C-scan plot of data with both x and y coordiantes. The image is achieved via a wireframe plot that is made solid. The histogram plot would leave too many blank spaces that are undesirable.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2025년 5월 2일
pointsize = 20;
scatter(x, y, pointsize, Dataset(:))
This will produce colored round dots at the given locations.
Producing square or rectangular dots would be more work.
  댓글 수: 2
Walter Roberson
Walter Roberson 2025년 5월 3일
Ah, I guess you can specify square markers for scatter() if you need to plot squares.
Sam Hurrell
Sam Hurrell 2025년 5월 5일
Is there any way to merge the scatter points to create an image that looks like the attached?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by