How to display values from a colorbar on surface?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone, I'm plotting a surface that shows frequency of appearence of clusters, I added a colorbar to make it easier to understand, but I'm facing some problems:
1. Can the colorbar have a label? like "number of hours the phenomena appears"?
2. Can the actual value of the variable be displayed on the graphic. I mean, with colorbar I see colours on the graphic, that correspond to a certain scale. Apart from the colours, is it possible to display the value as it is possible to do with contours?
Thanks a lot everyone, I copy the code I'm using next:
HS=RPHs; TP=RPTpr;
validi=HS>0&HS<50&TP<50&TP>0;
TP=TP(validi); HS=HS(validi);
figure(77) subplot(3,1,1) plot(HS,'.-') subplot(3,1,2) plot(TP,'.') subplot(3,1,3) plot(HS,TP,'.')
max_H=6;max_P=18; DH=0.1;DP=0.5; NGH=max_H/DH;NGP=max_P/DP; PH=[NGH,NGP]; for gH=1:NGH for gP=1:NGP PH(gH,gP)=length(find(HS>=DH*(gH-1)&HS<DH*gH&TP>=DP*(gP-1)&TP<DP*gP)); end end [PP,HH] = meshgrid(DP:DP:max_P,DH:DH:max_H);
%% Calcolo potenze ed energia
PH=(PH)/(sum(sum(PH)))*24*365; % Per quante ore l'anno ho un dato stato di mare
LL=PP.^2*9.81/2/pi; %lunghezze d'onda %[HH,LL] = meshgrid(DH:DH:max_H,DL:DL:max_L);
POT=((HH.^2).*PP); % Potenza nel piano H-P POT_SPEC=(1000*9.81^2)/(64*pi)/1000*POT; % 64 e non 32 se è Hs (kW/m) Potenza con coefficienti (H non è HS)
DEN_POT_TOT=(POT_SPEC.*PH); % Energia su ogni cluster di onde EN_ONDA_ORA=sum(sum(DEN_POT_TOT));
POT_AV=EN_ONDA_ORA/24/365; POS=num2str(round(POT_AV*100)/100);
%% Faccio grafici energia
scrsz = get(0,'ScreenSize'); figure('Position',[0.1*scrsz(3), 0.25*scrsz(4), 0.6*scrsz(3), 0.6*scrsz(4)]); PPL=['Frequency of appearance of Hi-Tj pairs - Rio de la Plata 09-11']; % subplot(2,2,1:2) title([PPL]) surface(PP,HH,PH) xlabel('Peak Period (s)') ylabel('Significant Wave Height (m)') axis([PP(1,1) 12 HH(1,1) 5]); set(gca, 'PlotBoxAspectRatio',[1 1 1]); colorbar set(gcf,'Renderer','Zbuffer') print ('-djpeg', '-r300', [PPL,'. Scatter frequenze.jpg'])
% subplot(2,2,3) figure('Position',[0.1*scrsz(3), 0.25*scrsz(4), 0.6*scrsz(3), 0.6*scrsz(4)]); title({'Frequency of appearance of Hi-Tj pairs in hours';['Average Power every linear metre = ',POS,' kW/m']}) %surface(HH,LL,PH') surface(PP,HH,DEN_POT_TOT) xlabel('Peak Period (s)') ylabel('Significant Wave Height (m)') axis([PP(1,1) 12 HH(1,1) 5]); caxis([0 1000]) set(gca, 'PlotBoxAspectRatio',[1 1 1]); colorbar set(gcf,'Renderer','Zbuffer') print ('-djpeg', '-r300', [PPL,'. En-Periodo.jpg']) % % subplot(2,2,4) figure('Position',[0.1*scrsz(3), 0.25*scrsz(4), 0.6*scrsz(3), 0.6*scrsz(4)]); title(['Average Power every linear metre = ',POS,' kW/m']) surface(LL,HH,DEN_POT_TOT) xlabel('Wave Length (m)') ylabel('Significant Wave Height (m)') axis([LL(1,1) 400 HH(1,1) 5]);caxis([0 1000]) set(gca, 'PlotBoxAspectRatio',[1 1 1]); colorbar set(gcf,'Renderer','Zbuffer') print ('-djpeg', '-r300', [PPL,'. En-Lungh.jpg'])
1 Kommentar
Tom
am 24 Feb. 2012
I can't run your code- RPHs and RPTpr are undefined.
But, for the first part of your question, try something like:
C=colorbar;
C_y=get(C,'ylabel');
set(C_y,'String','number of hours the phenomena appears')
Antworten (0)
Siehe auch
Kategorien
Mehr zu Colormaps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!