Creation of line between axis and point in scatterplot?

8 vues (au cours des 30 derniers jours)
Jeppe Sørensen
Jeppe Sørensen le 3 Nov 2013
Commenté : Image Analyst le 3 Nov 2013
The question pretty much says it all. How do you visualise a line between any point (even a moving point), directly towards the x-axis?

Réponses (1)

dpb
dpb le 3 Nov 2013
doc line % maybe???
There's a topic on animation techniques in the section on enhancing graphics that may be useful as well...
But in general,
hold on
line([x x]', [y 0]')
will add the line. For more generality, use
yl=ylim; yl=ylim(1);
for the 0 to get the value of the y axis lower limit
Image Analyst noted that--
If it's a moving point, you'll have to get the handle to the line so you can delete it when you draw the next one.
hLine = line(......
% move coordinates, then
% delete last line
delete(hLine);
% Draw new line
hLine = line(................
To which dpb agreed but noted that there's an easier way:
Do need the handle, yes...but only need to update the data point(s) that are moving/moved from one to another in the [x|y]data properties, not actually delete old/draw new but just change the data in the one...that automagically erases the other.
hL=line([x x]', [y 0]');
...something that changes x and y...
set(hL,'xdata', [x x], 'ydata', [y 0]);
  2 commentaires
Jeppe Sørensen
Jeppe Sørensen le 3 Nov 2013
Thank you very much. That was exactly what I needed!
Image Analyst
Image Analyst le 3 Nov 2013
Then please mark it as "Accepted" so dpb can get credit for it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Exploration 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!

Translated by