How to create a plot with highlight (holes) based on Y value and colored density map based on X value

2 ビュー (過去 30 日間)
Hi Team,
can you please teach me how to plot the following
I start with 2 sin function addition.
>> t = [0:0.0001:0.4*pi];
y=cos(100*t) + cos(110*t);
plot (y)
Then can you please help me with
  1. highlight the data points with bubble whose Y value is less than 0.5 but great than -0.5 (as in the pic below)
  2. include a density heat map along the X axis with the relative density of the highlighted data points. (red means the highlighted data is very concentrated and blue means the highlighted data is very scarce)
The plot attached is more or less capture the requirement 1.
Thank you

採用された回答

Voss
Voss 2021 年 11 月 30 日
To do #1, add the following lines of code after your plot(y) line:
hold on
idx = y>-0.5 & y<0.5;
plot(t(idx),y(idx),'o');
  6 件のコメント
Minghao Dong
Minghao Dong 2021 年 12 月 2 日
Thanks great!
You are the man!
Thank you!
Voss
Voss 2021 年 12 月 2 日
Great, glad it's working! Do you mind marking my answer as Accepted so that the question doesn't show up when other users browse unanswered questions (and also so I get credit for an accepted answer, of course)? Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by