Data editing

 

 

 

Plt has the capability to modify the plotted data, either one point at a time or over a specified range. Data entry is accomplished by entering the coordinates via the keyboard or by using the mouse when hyper accuracy is not required. (Note that an alternate method of data editing appropriate for short data sequences is described in the Menu box section.)

First position the cursor on the trace and data point you wish to modify. Then click the mouse one or more times to the left of the main axis (i.e. near the left edge of the figure window). As you do that, the shape of the cursor will rotate among these choices:

 

Cursor shape Use
Δ Move the selected point up or down (i.e. the x coordinate is not allowed to change)
Move the selected point left or right (i.e. the y coordinate is not allowed to change)

Move the selected point anywhere

After you have selected the cursor shape appropriate to your desired action, simply drag the cursor to its new location. Unless you selected the diamond shaped cursor, the motion of the cursor will be limited as specified above. When you let go of the mouse button after dragging the cursor to a new location, the cursored data point will be modified and the plot will immediately show the altered data. You can also change the data associated with the cursored point by typing in the new x or y value (or both) into the x and y-cursor edit boxes. When changing the data by typing in the new coordinates, it doesn't matter which of the cursor shapes you use. After selecting any of  the three cursor shapes in the above table you may enter the x or y value or both using the cursor edit boxes. You may also combine the data entry methods. For example, select the Δ cursor shape and drag the cursor to the desired y position. Then enter the x-coordinate of the desired x position into the x-cursor edit box.

The methods described so far only change the position of a single (x,y) data point. Sometimes however you may want to modify a range of points. A slight modification of the above method is used to do this. Instead of dragging the Δ,►, or ◊ cursor with the left mouse button, drag it with the right button. When you let go, instead of just changing the current point as before, plt modifies all the points from the previously edited position to the current cursor point (in a linear fashion). This may sound a little confusing, but just try it and you will probably find it quite intuitive. Note that it doesn't make sense to do the right-drag on the very first time you are editing a particular trace since the operation needs a properly defined starting point. In fact if you try that anyway, no data will be modified.

Note that we still need a way to specify that we want to modify a range of points when entering data thru the x or y-cursor edit boxes. Sorry, this is a bit obscure, but the way you do this is to type an "i" after the number. For example, typing 6.7 into the y-cursor edit box would change the y coordinate of  the data at the cursored location to 6.7,  however typing 6.7i would change the y coordinate of all the data between the current cursor and the previously edited cursor location. Think of the i as a tag equivalent to using the right mouse button instead of the left. (Why is the letter i used? Don't ask. It has to do with a Matlab programming trick.)

Note that none of the data editing operation described so far change the number of points that a line contains, so finally we have one more data editing option. Instead of left clicking in the area near the left edge of the figure window, try right clicking instead (one or more times) in that area. You will note that the cursor changes (in turn) to the same shapes shown in the table above. However the marker will be somewhat larger, reminding you that you are in the alternate data editing mode. As before, you can move the funny shaped editing cursor by dragging it to a new location or by typing a value into the x or y cursor edit boxes. The effect of this is similar to the normal data editing mode except that instead of modifying the cursored location, a new point is inserted into the trace after the cursored location. If however you drag the editing cursor below the x-axis, then the cursored location will be deleted from the trace. To summarize, the alternate data editing mode (enabled by right clicking to the left of the main axis) either increases or decreases the number of points in the trace by one.

In rare situations, you can't enter data editing mode this way because there may not be enough blank space to the left if the main axis. Also a command such as setappdata(gcf,'NoEdit',0); can be used to disable this method. For either of those two situations, alternate methods are provided for selecting the data editing modes as follows: Right clicking on the x-cursor edit box enters the normal data editing mode (equivalent to left clicking in the region to the left of the main axis). Right clicking on the y-cursor edit box enters the alternate data editng mode (equivalent to right clicking in the region to the left of the main axis).

Normally the 3 data editing cursor shapes appear in the order shown in the table above. So when you first right click on the x or y cursor edit boxes the upward pointing triangle cursor shape appears, allowing you to edit the y-values of the trace. (This is first since this is the most common editing need). To get the diamond shape allowing you to modify the x and y values, you need to right click on the edit box three times. In some applications, you always want to edit both the x and y values and so it would be nice if the diamond shape appeared on the first right click. You can get this behavior by putting a non empty value into the figure application data key called DataEdit . (i.e. use the statement setappdata(gcf,'DataEdit',0); )

If you want to save the altered data (to a file for example) you have to get the data from the 'xdata' and 'ydata' properties of the line handle. (Remember the line handles are returned by the plt call.) When the user modifies any data using these data editing functions, plt executes the user specified move cursor callback. (See the description of the 'set','moveCB' function here.) The callback routine can use the 'NewData' application property of the current figure window to determine data has been modified (as opposed to an ordinary cursor movement). For example:

if getappdata(gcf,'NewData') data_has_been_modified_action();

Also you can get the index into the xdata and ydata line properties of the last modified data using:

index = getappdata(cur,'i');

where cur is the handle of the active cursor.