File Exchange

image thumbnail


version (3.32 KB) by paul koch
function to shift a selected line (or all other outputs of the PLOT-function) in X and Y-direction

1 Download

Updated 25 Apr 2009

No License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

this function might be useful for quick and dirty visual inspection of multiple traces or timecourses with a timedelay between or arbitrary x/y-axes or illconditioned overlay of traces
- works for all outputs of the 'plot-function' (type is 'line').
- Note, plotet dots are also of type line.
- The function adds an icon in the menubar of a figure, which than
activates the shift-function
- if the function is active, a line can be selected and moved within the axis as long as the
mousebutton is not released
- right mouse button (contextmenu): get the original plot (as long as the icon in the menubar is
not deactivated)
plot(something);%plot something
uilineshift; %adds icon in menubar
OR 2]
uilineshift; %adds icon in menubar
now plot something
uilineshift('test'); %3 examples
Paul S. Koch, BNIC Berlin 2009

Cite As

paul koch (2021). uilineshift (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Todd Welti

Very Nice. I disabled the x-axis by remming out lines 231,250,251,274. Since I normally plot using semilogx, the x axis shifting doesn't work well as is. An option for x or y only shift would be nice. A little display showing the current value of shift would be nice too. Very usefull as is though...


Andrew Scott

Nice, but the demo requires "hanning", which is a signal processing toolbox function.


I thought is would be useful to show the difference between the current line and the original lines. This would be useful if you are trying to find a offset value for instance. If you add this after line 248 or so then the difference will display in the command window:

x_diff = s.x(1)-s.xorig(1);
y_diff = s.y(1)-s.yorig(1);
disp(['New Location Difference: x: ',num2str(x_diff), ' y: ',num2str(y_diff)])

This was a quick and dirty way to get the difference. Better yet the difference would display on the plot somehow.


Extremely useful. I don't know how many times I have had to do this manually.

It would be nice if this worked for simulink scopes.

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: plot_shift.m

Community Treasure Hunt

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

Start Hunting!