Is it possible to use tiledlayout to create a figure with plots and a PDF image? (per attachment)
Show older comments
Is it possible to use tiledlayout to create a figure with plots and a PDF image (or other vector image)? (per attachment)
tiledlayout nexttile recognizes different "plot" commands. How would I get nexttile to recognize a PDF image as a plot? And then add a title to the image just like a plot title?
Or is there a bettery way to do this than using tiledlayout?
Accepted Answer
More Answers (1)
Pratyush Swain
on 21 May 2024
Hi AP,
Using "tiledlayout" in MATLAB, you can create a figure that includes both plots and images.But MATLAB doesn't support PDF images for this purpose, you can leverage external tools to convert pdf to an image format (such as PNG/JPG) and then display it using the "imshow" or "imagesc" function within the "tiledlayout"
% Create a tiled layout
t = tiledlayout(2,2);
% Plot exapin the first three tiles
nexttile;
plot(rand(10,1));
title('MATLAB Plot');
nexttile;
plot(sin(1:0.1:10));
title('MATLAB Plot');
nexttile;
plot(cos(1:0.1:10));
title('MATLAB Plot');
% Display an image in the fourth tile
nexttile;
% Read the converted PDF image
img = imread('path to your image');
imagesc(img);
% You can add a title too
title('Image Plot');
I tried the implementation with a demo image and this was the output:

For more information on nexttile, you can refer to https://www.mathworks.com/help/matlab/ref/nexttile.html
Hope this helps.
Categories
Find more on Creating and Concatenating Matrices 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!