Plot size varies even when plotting in a loop

조회 수: 4 (최근 30일)
Adhiraj Dasgupta
Adhiraj Dasgupta 2020년 1월 20일
답변: Prabhan Purwar 2020년 1월 23일
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
dpb
dpb 2020년 1월 20일
If you want a specific resolution, use the key -r on the command line followed by the desired resolution.

댓글을 달려면 로그인하십시오.

답변 (1개)

Prabhan Purwar
Prabhan Purwar 2020년 1월 23일

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by