what is the most efficient way to write multiple plots to the local drive?
4 views (last 30 days)
Show older comments
More than 1.5 million plots must be saved to my local drive before my deep network trained.
What is the best way to write this bunch of plots efficiently?
is there any way to write with graphics (GPU)?
here is my code.
figure('visible','off','position',[0,0,244,244]);
parfor i = 1:numel(data)
line_width = 1;
clf,hold on;axis off;
for j = 1:numLines
plot((data{i,1}(j,:)),'LineWidth',line_width);
end
imFileName = [num2str(i) '.jpeg'];
exportgraphics(gca,imFileName);
end
data is a cell with size of 1000000*1
and each cell size is 10*100
All of them need to be saved not to plotted , but it takes many days!
2 Comments
dpb
on 5 Feb 2023
"More than 1.5 million plots must be saved...."
I fail to understand why the plots would have to be saved and what possible use could be made of that many plots even if did?
What do you really need -- the x,y pairs of data inside the plots, maybe? Even if so, there has to be a much more efficient way to approach the end problem, whatever it is...
Answers (2)
Sulaymon Eshkabilov
on 5 Feb 2023
In terms of time efficiency, exportgraphics() is faster than saveas().
Walter Roberson
on 5 Feb 2023
Some performance tune-ups
parfor i = 1:numel(data)
persistent fig ax lines
line_width = 1;
if isempty(fig)
fig = figure('visible','off','position',[0,0,244,244]);
ax = axes(fig);
end
cla(ax);
plot(ax, data{i}.', 'LineWidth', line_width); %plot each ROW
axis(ax, 'off');
imFileName = i + ".jpeg";
exportgraphics(ax,imFileName);
end
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!