How to plot vertical lines for each data point?
Afficher commentaires plus anciens
I have a line graph plot which is giving me a correct figure looking like the following:

However, my task is to recreate a zonation simulating the following figure:

I therefore need to add vertical lines to the plot at each data point along the x axis.
Any help would be greatly appreciated.
Réponse acceptée
Plus de réponses (1)
Ameer Hamza
le 11 Mar 2020
Modifié(e) : Ameer Hamza
le 11 Mar 2020
Check this example
% Example data
x = logspace(0,1,30);
y = log(x);
% plot original line
plot(x,y);
hold on;
% plot vertical lines
line_coordinates = [x' x' zeros(size(x')) y'];
line_coordinates = mat2cell(line_coordinates, ones(numel(x),1), [2 2])';
line_coordinates(3,:) = {'k'};
plot(line_coordinates{:})

3 commentaires
Victoria Wilson
le 11 Mar 2020
Modifié(e) : Victoria Wilson
le 11 Mar 2020
Ameer Hamza
le 11 Mar 2020
Check Steven's answer. It mentions a cleaner solution.
Victoria Wilson
le 11 Mar 2020
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!