필터 지우기
필터 지우기

scatter 2d plot with value in color

조회 수: 25 (최근 30일)
Miraboreasu
Miraboreasu 2022년 6월 11일
답변: DGM 2022년 6월 11일
clear
x=1:5;
y=1:6;
data=linspace(1,300,30);
figure()
scatter(x,y,[],data,'filled')
colorbar
colormap jet
xlabel('x')
ylabel('y')
Hi I am trying to plot a 2D scatter, each point's coordinate is in the vectors x and y, so there are total 5 times 6 30 points, and their value is the vector data. I want to a 2D plot with value show in the color
And if I use meshgrid(x,y), how make it 5 x 6, not a 6 x 5 matrix

채택된 답변

DGM
DGM 2022년 6월 11일
It's not really clear, but here's a guess
% two unequal length vectors
x = 1:5;
y = 1:6;
% assuming the vectors imply a uniform rectangular mesh
[xx yy] = meshgrid(x,y);
% is the "data" just a linear series?
data = linspace(1,300,30);
scatter(xx(:),yy(:),[],data,'filled')
colorbar
colormap jet
xlabel('x')
ylabel('y')

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by