Is it possible to use tiledlayout to create a figure with plots and a PDF image? (per attachment)
Mostra commenti meno recenti
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?
Risposta accettata
Più risposte (1)
Pratyush Swain
il 21 Mag 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.
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
