Best fit lines tend to imply an ordering to the data, but scatter plots tend to imply the data might not be ordered in a way that is compatible with fitting.
But yes, if you have polynomial coefficients for your fit, such as coefficients generated using polyfit(), then you can use polyval() to interpolate values, and you can "hold on" and plot() the values.
That code already plots multiple lines on the same plot. However, the y range of the second one is much larger than the y range of the first, so the second one takes up most of the space.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
2 Comments
tayyaba khurshid (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/23591-how-do-i-combine-multiple-plots-in-one-graph#comment_433968
Chiemela Victor Amaechi (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/23591-how-do-i-combine-multiple-plots-in-one-graph#comment_593667
Sign in to comment.