user3177755
user3177755

Reputation: 27

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? enter image description here

Thank you in advance

Upvotes: 0

Views: 1848

Answers (1)

phyrox
phyrox

Reputation: 2449

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.

Upvotes: 1

Related Questions