Reputation: 1
I have loaded in a lot of data from recordings on an electrode grid and want to plot the traces from each electrode on a figure with multiple subplots, one for each electrode.
for traces = 1:rows*columns;
subplot(rows,columns,traces);
baseline = mean(EX_output(1:baseline_time,traces));
plot(EX_output(1:timepoints,traces));
axis([000 timepoints baseline-60 baseline+60])
axis off
disp(traces); %print out trace completed
end
There are 900 traces (30x30). This works and produces a figure, but it takes a long time (2-3 hours).
When it finishes a trace, I have it print out the number. It appears to be fast up to around 300, but begins to slow down after that and continues to slow down. How can I speed up the plotting process?
Upvotes: 0
Views: 1047
Reputation: 1845
If you type edit subplot
and look at line 378 you see it checks all siblings of the figure when you subplot. This means that the more subplots you already have, the more it needs to check. I would expect this is the reason it slows down. If you call it and declare the parent figure explicitly you can speed it up a bit by also declaring the subplot as new.
f=figure(1);clf
f.NextPlot='new';
cols=20;rows=20;
tic
for idx = 1:(cols*rows)
subplot(rows,cols,idx,'Parent',f);
%subplot(rows,cols,idx);
end
toc
On my pc this brings the time to make a 20x20 figure down from 10 seconds to 6 seconds.
Oh, and I totally agree with the comments above. I see no practical use for 30x30 subplots, because the individual plots will be too small to see anything.
Upvotes: 2