Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7788257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:56:21+00:00 2026-06-01T20:56:21+00:00

How would I move an image along the x or y axis by clicking

  • 0

How would I move an image along the x or y axis by clicking a button?

I have imported the image with ‘image = imread(‘image.jpg’);’ and then use ‘Left = uicontrol(‘Parent’, gcf, ‘Style’, ‘pushbutton’, ‘String’,’Left’,…’, but I am stuck there. I would like to move the image in any direction.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:56:23+00:00Added an answer on June 1, 2026 at 8:56 pm

    You can create a simple callback function for the pushbutton, that changes XLim and YLim properties of axes showing the image.

    Save the original limits:

    xl = xlim;
    yl = ylim;
    

    For example to move image to the left:

    step = 5; %# move by 5 pixels
    xlim(xlim+step)
    

    To move up:

    ylim(ylim+step)
    

    To restore the original position:

    xlim(xl)
    ylim(yl)
    

    UPDATE:

    Here is a working sample code (without using GUIDE):

    im = imread('pout.tif');
    imshow(im);
    step = 5;
    xl = xlim;
    yl = ylim;
    pbLeft = uicontrol('Parent', gcf, 'Style', 'pushbutton', 'String','Left', ...
        'Units','norm', 'Position', [0.4 0.05 0.1 0.05], 'Callback', 'xlim(xlim+step)');
    pbReset = uicontrol('Parent', gcf, 'Style', 'pushbutton', 'String','Reset', ...
        'Units','norm', 'Position', [0.5 0.05 0.1 0.05], 'Callback', 'xlim(xl);ylim(yl);');
    pbRight = uicontrol('Parent', gcf, 'Style', 'pushbutton', 'String','Right', ...
        'Units','norm', 'Position', [0.6 0.05 0.1 0.05], 'Callback', 'xlim(xlim-step)');
    pbUp = uicontrol('Parent', gcf, 'Style', 'pushbutton', 'String','Up', ...
        'Units','norm', 'Position', [0.5 0.1 0.1 0.05], 'Callback', 'ylim(ylim+step)');
    pbDown = uicontrol('Parent', gcf, 'Style', 'pushbutton', 'String','Down', ...
        'Units','norm', 'Position', [0.5 0.0 0.1 0.05], 'Callback', 'ylim(ylim-step)');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two XmlDocuments and I would like to move an XmlNode selected from
I have a Pylons app where I would like to move some of the
If I would to move the image like 50px from the top of the
I would like to move and rotate an image of a ball in a
I have an App and in my touchesBegan, I move an image to another
I have about 10 images I draw on canvas in html5. Then, I would
I have a canvas in which I have an image. I can move that
I am using Jython to move images around and organise them. I would like
We are currently determining if we would move CVS and VSS projects to a
I would like to move a file or folder from one place to another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.