How to move colorbar inside the subplot ?

26 visualizaciones (últimos 30 días)
Andi
Andi el 5 de Abr. de 2022
Comentada: Andi el 6 de Abr. de 2022
Hi everyone,
I need to move colorbar inside the subplot along with some secondry edits e.g. highlight a region and add text and symbolic show of highest value.
Here is my script:
clear all
clc
ev_hr=readmatrix('U.csv');
ev_hr=ev_hr';
ev_bg=load('BG.txt');
bbb=ev_bg; % rate calculation
for S=1:1
uu=S;
r=bbb(uu); % for first event
data=ev_hr(:,uu);
u=transpose(data);
for n=1:length(u);
dt=n;
for i=1:length(u)-(n-1);
K=u(i:i+n-1);
k=sum(K);
b(i,n)=(k-(r)*(dt))/sqrt(r*dt);
end
end
T=transpose(b);
for ii=1:72
for jj=1:72-(ii-1)
if(ii==1)
b1(ii,jj)=T(ii,jj);
else
b1(ii,jj+(ii-1))=T(ii,jj);
end
end
end
% b=b1
for ii=1:length(b)
for jj=1:72
if(b1(ii,jj)==0)
b1(ii,jj)=nan;
end
end
end
c = NaN(72,24);
c2=[c b1];
x = [-23:72]' ;
y = [1:72]' ;
figure;
subplot(2,1,1); pcolor(x,y,c2);
shading interp ;
cb = colorbar
%cb.Position = [-20 10 -17 60];
ylabel('Time interval (hr)')
xlabel('Time (hr)')
xline(0,'--r');
A=readmatrix('hourly_ev.csv');
A=A';
uuu=A(:,uu);
ss=sum(uuu);
ss=ss+20
bb=cumsum(uuu);
nn=0;
tt=nn+1;
a=bb(:,tt);
j=uu(:,1);
h=[-23:72];
subplot(2,1,2); plot(h,bb, 'b')
ylabel('Cum. ev')
xlabel('Time (hr)')
xline(0,'--r');
axis([-23 72 0 ss])
end
Here is what i get so far:
and here is what i am expecting:

Respuesta aceptada

Voss
Voss el 6 de Abr. de 2022
Here's how to do some of the things you don't have yet:
data = (1:10)+randn(1,10);
ylimits = [floor(min(data)) ceil(max(data))];
axes('XGrid','on','YGrid','on', ...
'Box','on','Layer','top','Nextplot','add');
patch([6 7 7 6],ylimits([1 1 2 2]),[0.8 0.8 0.8], ...
'EdgeColor','none');
plot(data,'LineWidth',2,'Color','k');
ylim(ylimits);
cb = colorbar('Location','west');
text(6,ylimits(2),sprintf('\\beta_{max} = %.2f',11.03), ...
'VerticalAlignment','top');

Más respuestas (0)

Categorías

Más información sobre Language Support en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by