Plot size varies even when plotting in a loop
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I wrote a loop that reads a set of data files, makes a plot using the data in each file, exports the plot to a png file, and continues.
Since this is done in a loop using a counter, I expect the images saved in png format to be the same size and resolution. However, the images seem to be of different sizes/positions, so when I try to assemble the png files to produce a movie, the movie appears to flicker or jerk.
Here is the body of the loop. Any thoughts would be appreciated.
Thanks.
for it = 1: nt
data = dlmread([pathName0 timeList{it} '/' var '_planeXY.raw'], '', 2, 0);
x = data(:, 1);
y = data(:, 2);
z = data(:, 4);
t1 = num2str(t(it, 1)*1.0e03);
xlin = linspace(0, max(x), 300);
ylin = linspace(min(y), max(y), 300);
[X, Y] = meshgrid(xlin, ylin);
Z = griddata(x, y, z, X, Y, 'cubic');
h = figure();
colormap(jet);
grid off;
surf(xlin/1e-03, ylin/1e-03, Z, 'Edgecolor', 'none');
shading interp;
view(2);
cb = colorbar();
set(cb, 'ytick', [0 0.05 0.1 0.15 0.2]);
cbTitle = get(cb, 'Title');
set(cbTitle ,'String', varName);
caxis([0 0.2]);
ylabel('$r$ [mm]', 'Interpreter', 'latex', 'Fontname', 'Times', 'Fontsize', 40);
xlabel('$z$ [mm]', 'Interpreter', 'latex', 'Fontname', 'Times', 'Fontsize', 40);
title(['Time: ' t1 ' [ms]'], 'Fontname', 'Times', 'Fontsize', 40);
yticks([-30 -20 -10 0 10 20 30]);
xticks([0 10 20 30 40 50 60 70 80]);
ax = gca();
set(ax, 'Fontname', 'Times', 'Fontsize', 24);
axis([0 80 -35 35]);
print(h, '-dpng', [caseLES '/' timeList{it} '.png']);
close all;
end
1 commentaire
dpb
le 20 Jan 2020
If you want a specific resolution, use the key -r on the command line followed by the desired resolution.
Réponses (1)
Prabhan Purwar
le 23 Jan 2020
Hi,
Following links may help:
- https://in.mathworks.com/help/matlab/creating_plots/save-figure-at-specific-size-and-resolution.html (Save Figure at Specific Size and Resolution)
- https://in.mathworks.com/matlabcentral/answers/384848-get-figures-and-use-them-to-build-a-video-avi (Get figures and use them to build a video)
- https://in.mathworks.com/matlabcentral/answers/280635-make-video-from-images (Make video from images)
Hope it helps!!
0 commentaires
Voir également
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!