How to move colorbar inside the subplot ?
26 ビュー (過去 30 日間)
古いコメントを表示
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:
0 件のコメント
採用された回答
Voss
2022 年 4 月 6 日
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');
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!