Matlab Plotting problem

  • MATLAB
  • Thread starter JohnSimpson
  • Start date
  • #1

Main Question or Discussion Point

In my GUI I'm plotting a fairly large amount of data in an axes, and then plotting a horizontal line overtop that the user can control the vertical position of. Is there a way I can have the first plotted graph (the large amount of data) always be behind the line im plotting overtop, and have the user be able to dynamically move the line up and down the axes without having to re-plot both graphs every time the user wants to move the horizontal line?

For clarity, heres a picture

http://img229.imageshack.us/my.php?image=exampleya8.jpg

Again, I want the user to be able to dynamically move the line up and down without altering the blue signal (because it takes a while to re-plot the blue signal). Suggestions?
 

Answers and Replies

  • #2
Bump!
 
  • #3
Gonna give it one last shot
 
  • #4
809
0
Ok, I don't remember exactly how to do this, but I believe it has something to do with the 'erase' property when drawing.

Check out this link:
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/creating_plots/f10-1460.html&http://www.google.com/search?client=safari&rls=en-us&q=matlab+plotting+erase&ie=UTF-8&oe=UTF-8

Look at the part:
Erase Modes
...
none — The object is not erased when it is moved.
...



basically you do something like:
Code:
keep_me  = line('color','b','erase','none');
move_me = line('color','r','erase','normal'); 

keepX = [0 1 2 3 4];
keepY = [0 1 2 3 4];
set(keep_me, 'xdata', keepX, 'ydata', keepY);

moveX = [0 1 2 3 4];
moveY = [1 1 1 1 1];

set(move_me, 'xdata', moveX, 'ydata', moveY);
drawnow;

pause;

moveY = [2 2 2 2 2];

set(move_me, 'xdata', moveX, 'ydata', moveY);
drawnow;

Something like that.... treat that as pseudo code cause I'm trying to remember off the top of my head. I don't remember exactly if you need that drawnow in there, or (to be honest) when to use the drawnow.
 

Related Threads for: Matlab Plotting problem

  • Last Post
Replies
1
Views
2K
Replies
2
Views
1K
Replies
1
Views
1K
Replies
2
Views
2K
Replies
4
Views
913
  • Last Post
Replies
6
Views
1K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
1
Views
3K
Top