Creation of line between axis and point in scatterplot?

8 visualizaciones (últimos 30 días)
Jeppe Sørensen
Jeppe Sørensen el 3 de Nov. de 2013
Comentada: Image Analyst el 3 de Nov. de 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?

Respuestas (1)

dpb
dpb el 3 de Nov. de 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 comentarios
Jeppe Sørensen
Jeppe Sørensen el 3 de Nov. de 2013
Thank you very much. That was exactly what I needed!
Image Analyst
Image Analyst el 3 de Nov. de 2013
Then please mark it as "Accepted" so dpb can get credit for it.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by