how to plot to some maximum axis level?

2 ビュー (過去 30 日間)
Ani Asoyan
Ani Asoyan 2020 年 12 月 27 日
コメント済み: Ani Asoyan 2020 年 12 月 27 日
hi, I have variables with data, like
x= 20,12,15,65,74,52,233
y=55,2,221,23,21,21,11
I have done a scatter plot and added a trade line to it, but I want to plot that to some specific level of x axis. For example I want to set the maximum level of x to 70 and scatter plot it and add a trend line up to that value. How can I do that?
here is my code.
scatter( x, y, 'filled','LineWidth',1.5)
p = polyfit(x, y, 1);
px = [min(x) max(x)];
py = polyval(p, px);
scatter(x, y 'filled')
hold on
plot(px, py, 'LineWidth', 2);

採用された回答

Mischa Kim
Mischa Kim 2020 年 12 月 27 日
Add
axis([0 70 -inf inf])
  1 件のコメント
Ani Asoyan
Ani Asoyan 2020 年 12 月 27 日
Thank you !

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by