简体   繁体   中英

How to put in color a certain part of the background in a plot with matlab?

I would like to draw in grey color a certain part of the background in a plot. I know how to change the background color of the whole plot.I used this code after the plot function:

HANDLE = gca

get( HANDLE );

set( HANDLE, 'Color', [0.7,0.7,0.7] )

Exemple: y=x^2

How can I do to draw the blue part of the background in grey and to leave the other parts in white? 在此处输入图片说明

Thank you in advance

You can always draw a filled 2D rectangle with the desired color:

rectangle('Position',[-5,400,10,400],'FaceColor',[0.7,0.7,0.7])

So:

  1. Put your background in white
  2. Draw the gray rectangle
  3. Finally draw the curve.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM