- Of these, image() is the most basic of them, the closest to the internal graphics objects.
- imagesc() is the same as image() except that it configures the graphics object to scale the minimum data to be the first color and the maximum data to be the last color, no matter what the range of data is.
- imshow() is a convenience function that does a number of things besides just bringing up the image, such as enabling image tools and automatically activating a grayscale colormap for 2D data. imshow() can be frustrating to work with if you have anything other than the image inside the axes. I would not recommend it for your purpose.
How do I show an image inside a figure?
67 views (last 30 days)
Show older comments
Jesús Trujillo
on 4 Dec 2019
Answered: Walter Roberson
on 4 Dec 2019
So, I'm trying to show an image in the top right corner of the figure, I read the documentation but I still can't understand how to modify the axis of the image, this is the code I'm working on... Thanks!! PD. I'm quite new in matlab
x=300:1:2800;
y=0.0000006212*(x.^3)-0.0028922134*(x.^2)+2.6842821932*x+1733.6232694213; %Función Y
plot(x,y,'black')
hold on
for x=300:5:2800
y=0.0000006212*(x.^3)-0.0028922134*(x.^2)+2.6842821932*x+1733.6232694213; %Función Y
plot(x, y, '.b')
axis([200 2900 -100 2850])
title('Trayectoria del Vehículo')
xlabel('Eje Horizontal (x)')
ylabel('Eje Vertical (y)')
hold on
grid on
drawnow limitrate
end
0 Comments
Accepted Answer
Walter Roberson
on 4 Dec 2019
The three main functions to display an image in an axes are image(), imagesc(), and imshow() .
What I would recommend is that you call
image([lower_left_x, upper_right_x], [lower_left_y, upper_right_y], YourDataArray);
Here, the x and y coordinate pairs are the data coordinates at which to place the center of the lower left and upper right pixels. Be careful you do not use 0 or the upper size limit of your axes exactly or else a little bit of the image will be off-screen. For example,
image([200+1/2, 2900-1/2], [-100+1/2, 2850-1/2], YourImageArray);
to ensure that the edge of the image fits inside 200 to 2900 x, -100 to 2850 y
You would not typically create a new axes to put the image() into if you are just trying to add an image as an object into an axes that contains other things. You can create an axes to overlay (or underlay) an image onto something else, but you do not need to.
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!