Matlab Plotting: Move Horizontal Line Over Graph Without Re-Plotting

  • Context: MATLAB 
  • Thread starter Thread starter JohnSimpson
  • Start date Start date
  • Tags Tags
    Matlab Plotting
Click For Summary

Discussion Overview

The discussion revolves around dynamically moving a horizontal line over a plotted graph in MATLAB without the need to re-plot the underlying data. Participants explore methods to achieve this while maintaining the performance of the GUI, particularly when dealing with large datasets.

Discussion Character

  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant describes a scenario where a horizontal line needs to be controlled by the user, emphasizing the importance of not re-plotting the large dataset each time the line is moved.
  • Another participant suggests that the 'erase' property in MATLAB may be relevant for this task, specifically mentioning the 'none' mode to prevent erasing the object when it is moved.
  • A proposed approach involves creating two line objects: one for the static data and another for the movable line, with specific settings for their 'erase' properties.
  • Some code snippets are shared as pseudo code to illustrate how to set the data for the lines and potentially use the 'drawnow' function, although the exact necessity of 'drawnow' is uncertain.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the best method to implement the dynamic movement of the horizontal line, and there are uncertainties regarding the use of specific MATLAB properties and functions.

Contextual Notes

There are limitations in the discussion regarding the exact implementation details and the conditions under which certain MATLAB functions should be used. The effectiveness of the proposed methods may depend on the specific context of the GUI and the data being handled.

JohnSimpson
Messages
89
Reaction score
0
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 I am 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, here's 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?
 
Physics news on Phys.org
Bump!
 
Gonna give it one last shot
 
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/hel...-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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 10 ·
Replies
10
Views
5K
  • · Replies 9 ·
Replies
9
Views
4K
Replies
10
Views
5K
  • · Replies 2 ·
Replies
2
Views
5K