How to make graphic get the same color as the colorbar?
1 回表示 (過去 30 日間)
古いコメントを表示
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/661545/image.jpeg)
How can I make the graphic and the colorbar interact?
1 件のコメント
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
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/661595/image.jpeg)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!