How assign specific colours (different from the colourmap ones) to regions of a matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
simone ferrari
le 5 Avr 2020
Commenté : simone ferrari
le 6 Avr 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 commentaires
Ameer Hamza
le 5 Avr 2020
Can you attach you dataset as a mat file. It will make it easy for me to suggest a solution.
Réponse acceptée
Ameer Hamza
le 6 Avr 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]');
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Blue dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!