How assign specific colours (different from the colourmap ones) to regions of a matrix
2 ビュー (過去 30 日間)
古いコメントを表示
Hi!
After plotting a 2D matrix with pcolor and a jet colormap, I need to give some specific colours (e.g, black, green and brown)
to some specific regions of the figure (without using fill, too long to define every vertex). Thanks!
7 件のコメント
Ameer Hamza
2020 年 4 月 5 日
Can you attach you dataset as a mat file. It will make it easy for me to suggest a solution.
採用された回答
Ameer Hamza
2020 年 4 月 6 日
Try this code.
xplot_ph0 = loadmdm('xplot_ph0');
yplot_ph0 = loadmdm('yplot_ph0');
WindSpeed_ph0 = loadmdm('WindSpeed_ph0');
U_ph0 = loadmdm('FlowuSpeed_ph0');
V_ph0 = loadmdm('FlowvSpeed_ph0');
Map_ed_veg = loadmdm('Edifici_vegetazione_ph0');
Map_ed_veg_NaN = Map_ed_veg;
Map_ed_veg_NaN(Map_ed_veg==0) = NaN;
passo=30;
fig=300;
fig = fig + 1;
figure (fig);
WindSpeed_ph0 = 4*WindSpeed_ph0; % 4 is selected by trial and error, tune it as required
WindSpeed_ph0(~isnan(Map_ed_veg_NaN)) = Map_ed_veg_NaN(~isnan(Map_ed_veg_NaN));
pcolor(xplot_ph0,yplot_ph0,WindSpeed_ph0);
shading flat; axis square; colormap jet; caxis([0 20]); colorbar;
xlabel('X [m]'); ylabel('Y [m]');
hold on
q=quiver(xplot_ph0(1:passo:end), yplot_ph0(1:passo:end), U_ph0(1:passo:end), V_ph0(1:passo:end), 2);
q.Color='black';
hold off
fig = fig + 1;
figure(fig);
pcolor(xplot_ph0,yplot_ph0,Map_ed_veg_NaN);
shading flat;axis square; colormap jet; caxis([0 20]); colorbar;
xlabel('X [m]'); ylabel('Y [m]');
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Blue についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!