how to plot to some maximum axis level?

3 views (last 30 days)
hi, I have variables with data, like
x= 20,12,15,65,74,52,233
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);

Accepted Answer

Mischa Kim
Mischa Kim on 27 Dec 2020
axis([0 70 -inf inf])

More Answers (0)


Community Treasure Hunt

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

Start Hunting!