How to Place an image over existing plots?

Hello, I have some graphs in Matlab over which I want to insert a small image. I do not want to cover the graphs completely, and want to know how to specify the exact position for overlaying this image onto the existing plots. I have used imread to read the file, but cannot seem to figure out imshow to display the image properly where I would like it to be.

 Respuesta aceptada

Chad Greene
Chad Greene el 18 de Dic. de 2014
Hi Ashley,
Run this:
figure
plot((1:10).^2)
axes('pos',[.1 .6 .5 .3])
imshow('coins.png')
The axes command sets up a new set of axes on top of the x^2 plot, with the position of those axes as follows:
[bottomleftcornerXposition bottomleftcornerYposition width height]

4 comentarios

Ashley
Ashley el 18 de Dic. de 2014
Hello Chad, Thank you! It worked perfectly!
Ashley
Munish Sikka
Munish Sikka el 26 de Ag. de 2019
Hello Chad,
Thanks for this solution. it worked in my case too.
Regards,
JACQUES SPILLMANN
JACQUES SPILLMANN el 25 de Abr. de 2020
How would I go about rotating that picture on the plot, let's say, by 10 degrees clockwise?
I am inserting a particular image in my figure but the resolution of the inserted image gets distorted if I create a smaller box for that, why would that be?
This is what I am using but I don't see any resolution options.
[img, map, alphachannel] = imread(fileName,'png');
image(img, 'AlphaData', alphachannel);

Iniciar sesión para comentar.

Más respuestas (1)

DGM
DGM el 22 de Mzo. de 2023

0 votos

This doesn't necessarily require creating another axes object. This can be done directly by setting xdata/ydata for image/imagesc/imshow.
See the example:

Productos

Preguntada:

el 18 de Dic. de 2014

Respondida:

DGM
el 22 de Mzo. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by