Is it possible to plot the image of a pdf file within subplot?

24 views (last 30 days)
Hi all.
I have an image stored in a PDF file which I would like to display as a part of a subplot in Matlab (see attachment). Is this possible? Thanks!
  1 Comment
Jan
Jan on 22 Jan 2023
What is the problem exactly? Displaying an image a subplot? This is solved by the image() command easily. Or extracting the image from the PDF? If so, should the be done automatically? If so, how can the page and position of the wanted image be identified? Or do you want to extract the image manually, e.g. by AcrobatPro or other software to process PDFs? Do you mean a screenshot of the PDF or do you want to import a diagram in vector format?
Please edit the question and add more details.

Sign in to comment.

Answers (1)

Daksh
Daksh on 3 Feb 2023
It is my understanding that alongside MATLAB-created plots, you wish to put a PDF-contained image inside a plot layout created by subplot() method.
I'm assuming that you've already snipped the PDF portion of image of use as a file (eg. my_image.jpg) and saved it into the working directory. If not, proceed to use the Snipping Tool or any 3rd party screenshot and crop tool to save the image for use as a file.
Refer to this script for the next steps:
subplot(2,2,1)
x = linspace(0,10);
y1 = sin(x);
plot(x,y1)
title('Subplot 1: sin(x)')
subplot(2,2,2)
y2 = sin(2*x);
plot(x,y2)
title('Subplot 2: sin(2x)')
subplot(2,2,[3,4])
y3 = sin(4*x);
% use imshow() command that displays image for the given file path
imshow('my_image.jpg');
title('My Image')
This will yield the desired output, as showcased by you in the attached image. Hope this helps!

Community Treasure Hunt

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

Start Hunting!