How to 'divide' the x-axis based on y-values?

8 ビュー (過去 30 日間)
A
A 2016 年 2 月 27 日
編集済み: Konstantinos Sofos 2016 年 2 月 28 日
Here's a sample equation plot:
x = linspace(0,100);
y = @(x) log(x);
plot(x,y(x),'-','LineWidth',2);
And I am attaching three pictures which represent what I would like to have. I want to 'divide' and 'categorize' the x-axis based on certain ranges of y values. Is there a way I can accomplish one or all three of the tasks outlined in attached picture?
Thank you
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 2 月 27 日
no attached picture
A
A 2016 年 2 月 27 日
Fixed.

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

採用された回答

Konstantinos Sofos
Konstantinos Sofos 2016 年 2 月 27 日
編集済み: Konstantinos Sofos 2016 年 2 月 28 日
Hi,
There are really many and nice ways to take the desire output...here just one quick solution with some patches
x = linspace(0,100);
y = @(x) log(x);
plot(x,y(x),'--','LineWidth',2);
x_lim = get(gca,'xlim')
y_lim = get(gca,'ylim')
hold on
patch([0 0 exp(3.75) exp(3.75)],[y_lim(1) y_lim(2) y_lim(2) y_lim(1) ],[1 0.5 0.2],'FaceAlpha',0.2)
text(mean([0 exp(3.75)]),mean(y_lim),'y < 3.75','rotation',90,'FontSize',14,'HorizontalAlignment','center')
patch([exp(3.75) exp(3.75) exp(4) exp(4)],[y_lim(1) y_lim(2) y_lim(2) y_lim(1) ],[1 1 0.2],'FaceAlpha',0.2)
text(mean([exp(3.75) exp(4)]),mean(y_lim),'3.75 < y < 4.00','rotation',90,'FontSize',14,'HorizontalAlignment','center')
patch([exp(4) exp(4) x_lim(2) x_lim(2)],[y_lim(1) y_lim(2) y_lim(2) y_lim(1) ],[0.5 1 0.7],'FaceAlpha',0.2)
text(mean([exp(4) x_lim(2)]),mean(y_lim),'y > 4.00','rotation',90,'FontSize',14,'HorizontalAlignment','center')
grid minor
ylabel('ln(x)')
  1 件のコメント
A
A 2016 年 2 月 27 日
This is amazing. I am definitely going to try this out.
Is there any other way you can think of?
Thanks so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by