简体   繁体   English

如何使用Matlab在绘图中为背景的特定部分添加颜色?

[英]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: 我知道如何更改整个绘图的背景颜色。我在plot函数之后使用了以下代码:

HANDLE = gca 处理= gca

get( HANDLE ); get(HANDLE);

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

Exemple: y=x^2 范例: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: 您始终可以用所需的颜色绘制一个填充的2D矩形

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. 最后绘制曲线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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