How can I speed up image manipulation of a .fig?
3 views (last 30 days)
Show older comments
A collaborator sent me a .fig file depicting about 5000 points connected to their nearest neighbors by short line segments. It is meant to be representative of several units cells' worth of a crystal lattice. I do not have the details on how the figure was generated, but I can open it in Matlab.
When I open it on my laptop, it is painfully slow to rotate, zoom in, or pan the figure. This is to be expected because it is running an 8 year old i5 processor with integrated graphics. However, when I use my personal desktop with an excellent graphics card and 8-core i9, the speed of manipulating the figure is exactly the same.
I would like to know if there is a way to speed up manipulation of this .fig on either computer, or to somehow give Matlab access to my desktop's better processing power.
2 Comments
Walter Roberson
on 4 Apr 2022
Are all of the line segments the same color and same marker (if markers are used)?
Answers (2)
Jan
on 4 Apr 2022
Maybe. How is your OpenGL driver set up?
opengl info
Which Shading and Renderer in used in the figure?
Can you provide the figure?
Walter Roberson
on 5 Apr 2022
The following code replaces the lines for each axes with a single continuous line object that uses NaN to break up the pieces. It assumes that all the lines of an axes are the same size and color. It does not assume that there is only one axes. The idea is that the problem might be that there are too many plot objects to draw effectively.
This code makes no attempt to be "smart" about joining the lines.
fig = openfig('NameOfFigureFile.fig');
all_ax = findobj(fig, 'type', 'axes');
for ax = all_ax(:).'
these_lines = findobj(ax, 'type', 'line');
if isempty(these_lines); continue; end
xdc = get(these_lines, 'XData').';
xdc(2,:) = {nan};
xd = [xdc{:}];
ydc = get(these_lines, 'YData').';
ydc(2,:) = {nan};
yd = [ydc{:}];
lw = these_lines(1).LineWidth
st = hold(ax, 'on');
plot(ax, xd, yd, 'k-', 'LineWidth', lw);
hold(ax, st)
delete(these_lines);
end
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!