Plotting axis in the correct position

Context: I am coding a scanner, and one of the features is to take an ROI scan atop a larger scan. The end result should be the ROI scan pasted on top of the original, in the place of the selected ROI. One thing I noticed is that the position property of the rectangle is relative to the axis, but the position property of the axis is relative to the figure (the axis range could be for example -12 to 12 in the x and -12 to 12 in the y, and [x,y] = ginput(1) gives the correct coordinate. I want an ROI image between 3 and 5 in the x, and 3 and 5 in the y. But using axes('Position', [3 3 2 2] does not give the correct position for the ROI, it's somewhere offscreen.)

3 Comments

I'm not sure what it means, "I am coding a scanner".
When you say "I want an ROI image between 3 and 5 in the x, and 3 and 5 in the y", is that in data coordinates? If so, then you would specify the position of the ROI within the axes. Why would the axes position relative to the figure come into play?
Also, the position of the axes relative to the figure depends on the axes units. If the axes units are normalized and you're setting the axes position to 3 3 2 2 then it's not a surprise that the axes moves off of the figure. But I don't think you want to move the axes, anyway.
>I am not sure what it means "I am coding a scanner."
It is the project I am working on.
>When you say "I want an ROI image between 3 and 5 in the x, and 3 and 5 in the y", is that in data coordinates?
I'm not quite sure how to answer that question so let me rephrase: The x and y axis are in units of millimeters. I can select an ROI across some area (for example, 3mm to 5mm in the x, 3mm to 5mm in the y.) I don't have an issue selecting the ROI, my issue comes in when I try to place the axes within that ROI. The problem is, as you said, the position of the axis is normalized, which is relative to the figure. I need it to be relative to the axes values.
Just to clear up some terminology, the data units are mm. The axis units are normalized. The ROI is plotted on the axes; it's a child of the axes. So you cannot place the axes within the ROI but you could place the ROI within the axes.
It sounds like you just need to use xlim() and ylim() and perhaps axis equal or axis tight.

Answers (0)

This question is closed.

Tags

Asked:

on 23 Jun 2020

Closed:

on 24 Jun 2020

Community Treasure Hunt

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

Start Hunting!