How to make graphic get the same color as the colorbar?

조회 수: 2 (최근 30일)
João Micheletti
João Micheletti 2021년 6월 22일
댓글: João Micheletti 2021년 6월 23일
I'm using this command:
>> datl=importdata('D:\Testes\testes_feitos\poisson_numerico.txt');
>> x=datl(:,1);
>> y=datl(:,2);
>> z=datl(:,3);
>> plot3(x,y,z);
>> colorbar
>> grid on
And it gives me this:
How can I make the graphic and the colorbar interact?
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2021년 6월 22일
One way is to use mesh instead of plot3. Do so and the mesh colors will be linked to the colorbar

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

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 6월 22일
I think this achieves what you are after. Use mesh, instead of plot3, and the mesh colors will be linked to the colorbar:
% your x, y, and z data
datl = rand(10,3);
x = datl(:,1);
y = datl(:,2);
z = datl(:,3);
F = scatteredInterpolant(x, y, z);
xx = linspace(min(x), max(x));
yy = linspace(min(y), max(y));
[XX, YY] = meshgrid(xx, yy);
ZZ = F(XX, YY);
mesh(XX, YY, ZZ, 'facecolor', 'none');
colorbar;

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by