Fill background area between two x values in a graph

102 ビュー (過去 30 日間)
leonidas86
leonidas86 2018 年 6 月 7 日
編集済み: Aquatris 2020 年 11 月 21 日
Hello,
How can I fill a specified background area between two x values?
  1 件のコメント
dpb
dpb 2018 年 6 月 7 日
See
doc patch
and examples therein

サインインしてコメントする。

回答 (1 件)

Aquatris
Aquatris 2018 年 6 月 8 日
A simple and quick way is to fill a rectangle before you start your plot.
x1 = 0.4; x2 = 0.9;
y1 = 1; y2 = -1;
figure(1)
fill([x1 x1 x2 x2],[y1 y2 y2 y1],'r')
axis([0 2 y2 y1]),hold on
t = 0:1e-3:2*pi;
plot(t,sin(10*t))
  2 件のコメント
Carlee Toddes
Carlee Toddes 2020 年 11 月 20 日
if you have multiple x values that need to be patched (i.e.several sets of two data points that need to be discretely patched on a time scale) is there a function that can help with this
Aquatris
Aquatris 2020 年 11 月 21 日
編集済み: Aquatris 2020 年 11 月 21 日
Does the patch function not work for you? Here is the link.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePolygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by