How assign specific colours (different from the colourmap ones) to regions of a matrix
2 views (last 30 days)
Show older comments
simone ferrari
on 5 Apr 2020
Commented: simone ferrari
on 6 Apr 2020
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 Comments
Ameer Hamza
on 5 Apr 2020
Can you attach you dataset as a mat file. It will make it easy for me to suggest a solution.
Accepted Answer
Ameer Hamza
on 6 Apr 2020
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]');
More Answers (1)
See Also
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!