![](https://www.mathworks.com/help/examples/graphics2/win64/AddLinePlotToExistingGraphExample_01.png)
Plotting Two Data Sets on a Figure
2 次查看(过去 30 天)
显示 更早的评论
I have two sets of data which can be plotted as a sets of discrete points given by (x,y) coordinates on a 2D plot. Is there some way that I can manually plot both sets of points, join the points to have two separate curves for the two data sets and then have a legend corresponding to the points used for the plotting? If easier, I could enter the data sets as arrays by creating the matrix and then plotting from it.
I did something similar before in this case it was something like a scatter diagram whereas here I need to join the points.
0 个评论
采纳的回答
Cris LaPierre
2020-3-24
Something like this?
![](https://www.mathworks.com/help/examples/graphics2/win64/AddLinePlotToExistingGraphExample_01.png)
x = linspace(-pi,pi);
y1 = sin(x);
plot(x,y1)
hold on
y2 = cos(x);
plot(x,y2)
hold off
10 个评论
Cris LaPierre
2020-4-3
Bad example. Sorry. Yes, line styles don't apply if you are plotting the points one at a time. You'll need to use a marker. Check out the link I shared. That shows you the available marker styles.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!