Creation of line between axis and point in scatterplot?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
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
Ver también
Categorías
Más información sobre Data Exploration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!