How do i make the background colour of my plot change in certain areas?

5 次查看(过去 30 天)
Hi, so I have this plot, it could be like this:
a=[[1:1440]'];
Totalset=[a a*0 (sin(a./20)+2)*100 a*0 cos(a./20)*9+20]
AX=plotyy(Totalset(:,1),Totalset(:,5),Totalset(:,1),Totalset(:,3))
set(AX(2),'ydir','rev')
hold on
set(get(AX(1),'Ylabel'),'String','Kernetemperatur(C)')
set(get(AX(2),'Ylabel'),'String','Dybde(m)')
y_venstre_min=10
y_venstre_max=30
y_hojre_min=50
y_hojre_max=300
set(AX(1),'YLim',[y_venstre_min,y_venstre_max])
set(AX(2),'YLim',[y_hojre_min,y_hojre_max])
And, now I have this matrix:
MTRX=[1 0 1 0 1 0 1 0;23 75 149 400 600 1100 1300 1400]'
I want my background to change to dark grey when MTRX(:,1)=1, and back to white when it goes back to 0 etc. So that my background would be white from 0 to 23, dark grey from 23 to 75, white from 75 to 149, dark grey from 149 to 400, and so on.
Is this possible, and do anyone have an example to help me get started I spent some time looking for this, but could only find how to change the colour of the entire background?
Best regards, Nicki Eriksen

采纳的回答

Image Analyst
Image Analyst 2013-11-25
You'll probably need to use the patch() or fill() functions.
  1 个评论
Nicki
Nicki 2013-11-25
编辑:Nicki 2013-11-25
Yes, that should be possible, thanks for the hint, it's been like 3 years since I used those, so I completely forgot about them.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Two y-axis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by