How do I show an image inside a figure?

30 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2019-12-4
The three main functions to display an image in an axes are image(), imagesc(), and imshow() .
  • 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.
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 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by