Plot Line Over Multiple Axes Simultaneously

2 Ansichten (letzte 30 Tage)
Jeff Anderson
Jeff Anderson am 1 Jul. 2012
Hello all,
I am try to develop a GUI to play through data in time and examine different traces. Much like a audio recording interface. I'm having a difficult time getting the cursor behavior to work ok. I'm wondering if there is a better (faster) way to plot a vertical line over multiple plots rather than calling a for loop to loop through the axes. Here's what I mean (I define handles.cursor.xLocation from the mouse click position):
for j = 1:length(axesHandles)
axes(axesHandles(j))
yLimits = get(axesHandles(j),'YLim');
hCursor = line(handles.cursor.xLocation*[1 1],yLimits,'Color','r');
handles.cursor.handles(j) = hCursor;
end
This generates a considerable lag when plotting through this loop and was wondering if there was a better way??? Any help would be much appreciated!
Jeff

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 1 Jul. 2012
Bearbeitet: Walter Roberson am 1 Jul. 2012
You mention "cursor behavior". Does that imply you are moving the lines? If so then it is better to set() the XData and YData of each of the lines rather than creating a new line() object each time.
You do not need the axes() call, and it is slowing you down. Instead, specify the axes in the line() call:
handles.cursor.handles(j) = line( handles.cursor.xLocation([1 1]), yLimits, 'Color', 'r', 'Parent', axesHandles(j) );
(I also optimized the *[1 1] that was being used for replication.)
  1 Kommentar
Jeff Anderson
Jeff Anderson am 1 Jul. 2012
Thank you SO much!!! Works like a champ. And yes, that is exactly what I was doing is deleting and redrawing the cursor. Very inefficient. Your way is a great way of doing what I was trying to. Thank you so much for taking the time to post!!!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by