matlab 画图和保存图片
画图,这个例子简单来说是五组数据,记录了吉布斯采样过程中一个参数的变化过程,每组数据表示不同的初始化得到的采样。最后不同的初始化都快速收敛到比较接近的参数范围。
jobID = 45;
x=-25:25:1000;
x(1)=0;
x(2)=1;
style=['bo-'; 'gx-'; 'r*-'; 'c+-'; 'md-'];
figure
for taskID = 1:5
DATA = loadSamplerOutput( jobID, taskID );
data = loadSamplerInfo( jobID, taskID);
for i=1:length(DATA.Psi)
y(taskID,i)=size(DATA.Psi(i).F,2);
end
plot (x,y(taskID,:),style(taskID,:));
hold on
end
xlabel('iteration');
ylabel('interest number');
% legend(strcat('Init ',num2str(1*10)),strcat('Init ',num2str(2*10)),strcat('Init ',num2str(3*10)),strcat('Init ',num2str(4*10)),strcat('Init ',num2str(5*10)))
legend(strcat('Group ',num2str(1)),strcat('Group ',num2str(2)),strcat('Group ',num2str(3)),strcat('Group ',num2str(4)),strcat('Group ',num2str(5)))
保存为需要的各种格式的文件:
filename=strcat('../pic/Interestnum_',num2str(jobID));
print(gcf,'-dpng',filename)
print(gcf,'-depsc',filename)
print(gcf,'-djpeg',filename)
saveas(gcf,filename)
% -dps % PostScript for black and white printers
% -dpsc % PostScript for color printers
% -dps2 % Level 2 PostScript for black and white printers
% -dpsc2 % Level 2 PostScript for color printers
%
% -deps % Encapsulated PostScript
% -depsc % Encapsulated Color PostScript
% -deps2 % Encapsulated Level 2 PostScript
% -depsc2 % Encapsulated Level 2 Color PostScript
%
% -dhpgl % HPGL compatible with Hewlett-Packard 7475A plotter
% -dill % Adobe Illustrator 88 compatible illustration file
% -djpeg<nn> % JPEG image, quality level of nn (figures only)
% E.g., -djpeg90 gives a quality level of 90.
% Quality level defaults to 75 if nn is omitted.
% -dtiff % TIFF with packbits (lossless run-length encoding)
% compression (figures only)
% -dtiffnocompression % TIFF without compression (figures only)
% -dpng % Portable Network Graphic 24-bit truecolor image
jobID = 45;
x=-25:25:1000;
x(1)=0;
x(2)=1;
style=['bo-'; 'gx-'; 'r*-'; 'c+-'; 'md-'];
figure
for taskID = 1:5
DATA = loadSamplerOutput( jobID, taskID );
data = loadSamplerInfo( jobID, taskID);
for i=1:length(DATA.Psi)
y(taskID,i)=size(DATA.Psi(i).F,2);
end
plot (x,y(taskID,:),style(taskID,:));
hold on
end
xlabel('iteration');
ylabel('interest number');
% legend(strcat('Init ',num2str(1*10)),strcat('Init ',num2str(2*10)),strcat('Init ',num2str(3*10)),strcat('Init ',num2str(4*10)),strcat('Init ',num2str(5*10)))
legend(strcat('Group ',num2str(1)),strcat('Group ',num2str(2)),strcat('Group ',num2str(3)),strcat('Group ',num2str(4)),strcat('Group ',num2str(5)))
保存为需要的各种格式的文件:
filename=strcat('../pic/Interestnum_',num2str(jobID));
print(gcf,'-dpng',filename)
print(gcf,'-depsc',filename)
print(gcf,'-djpeg',filename)
saveas(gcf,filename)
% -dps % PostScript for black and white printers
% -dpsc % PostScript for color printers
% -dps2 % Level 2 PostScript for black and white printers
% -dpsc2 % Level 2 PostScript for color printers
%
% -deps % Encapsulated PostScript
% -depsc % Encapsulated Color PostScript
% -deps2 % Encapsulated Level 2 PostScript
% -depsc2 % Encapsulated Level 2 Color PostScript
%
% -dhpgl % HPGL compatible with Hewlett-Packard 7475A plotter
% -dill % Adobe Illustrator 88 compatible illustration file
% -djpeg<nn> % JPEG image, quality level of nn (figures only)
% E.g., -djpeg90 gives a quality level of 90.
% Quality level defaults to 75 if nn is omitted.
% -dtiff % TIFF with packbits (lossless run-length encoding)
% compression (figures only)
% -dtiffnocompression % TIFF without compression (figures only)
% -dpng % Portable Network Graphic 24-bit truecolor image
![]() |