Combining two plots and adding color to points
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Image Analyst
le 5 Mai 2015
Modifié(e) : Image Analyst
le 5 Mai 2015
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Scatter Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!