Combining two plots and adding color to points
1 次查看(过去 30 天)
显示 更早的评论
matrix=load('Data');
x = matrix(:,1);
y = matrix(:,2);
fprintf('The maximum distance between two points is %3.2f units.\n',hypot((max(x)-min(x)), (max(y)-min(y))))
plot([max(x),max(y)],[min(x),min(y)])
scatter(x,y)
title('Maximum Distace Achieved')
xlabel('X Values')
ylabel('Y Values')
I'm having two problems with this code: the first is that I somehow need to combine a plot with a scatterplot and the second is that the line in the plot needs to be red while all other points need to be blue. I would try to work with the colors myself but all explanations I've looked up on how to do color for a plot have been rather vague. So if you could help I would greatly appreciate it.
0 个评论
采纳的回答
Image Analyst
2015-5-5
编辑:Image Analyst
2015-5-5
Get rid of scatter and have two calls to plot
% Plot red lines between the two most separated points.
plot(plot([max(x),max(y)],[min(x),min(y)]), 'r-', 'LineWidth', 2);
hold on
% Plot blue stars at the points.
plot(x, y, 'b*', 'MarkerSize', 10);
grid on;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!