Can't export my plot to any format
7 views (last 30 days)
Show older comments
I have a 3d scatter plot I've generated and using either saveas() or export_figure found on the file exchange simply doesn't work. I get the same symptoms if I use .bmp or .png
I receive no error message, and Matlab seems to just enter an endless loop as it says Busy in the bottom left of the window.
Is there some limit to how many points I can plot and still be able to save/export the figure?
My current plot has somewhere around 150,000 triplets....
A = csvread('ALL_MARKS.csv'); %Open CSV with position and area data
A = A(:,1:4);
x = A(:,1);
y = A(:,2);
z = A(:,3);
zavg = mean(z);
zstdev = std(z);
SIZE = zeros(length(z),1);
for i = 1:length(z);
SIZE(i)=(z(i)-zavg)/zstdev;
end
SIZE = abs(SIZE);
cmap = z;
figure('color','white');
%colormap(jet(256));
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure
scatter3(x,y,z, SIZE, cmap, 'fill');
currentDirectory = pwd
[upperPath, deepestFolder, ~] = fileparts(currentDirectory)
Tfontargs = {'FontName','Arial','FontSize',12,'FontWeight','bold'};
Lfontargs = {'FontName','Arial','FontSize',12};
title(deepestFolder,Tfontargs{:});
xlabel('X-Position [mm]',Lfontargs{:});
ylabel('Y-Position [mm]',Lfontargs{:});
%zlabel('Area [mm^2]');
axis equal; %Square and set axes to tested area
axis([-2500 2500 -400 12000 0 10000]);
view(90,90); %Change plot view to 'overhead view'
load('BWMap','mycmap') %Load and set a custom colormap
set(gcf,'Colormap',mycmap)
hcb = colorbar('Location','SouthOutside');
set(hcb,'XTickMode','manual');
xlabel(hcb,'Area [mm²]',Lfontargs{:});
saveas(gcf, 'test.png')
0 Comments
Answers (1)
Walter Roberson
on 16 Jun 2013
It looks plausible to me that the saveas() might be the first point in your code that forces the points to be rendered. If so then it might not be the save but rather the rendering. You could find out by tossing in a drawnow() before the saveas, and display a message after that: if the message does not appear then the rendering is the problem.
150,000 triplets is a lot. That is roughly the equivalent to painting every pixel in a 387 x 387 square. On a 1280 x 1024 screen, about one pixel in 8 would be filled if each marker was only 1 pixel (but by default markers are about 18 pixels). It sounds unlikely that the plot would be readable.
Have you considered reducing the density, or rendering the coordinates yourself into an array and then drawing the array? I notice that you set the marker size according to a deviation, but you also set the color according to deviation, so possibly you could combine the two, such as by using color-coded fixed-size markers? The marker to plot would be the one corresponding to the highest z at the pixel.
2 Comments
Walter Roberson
on 17 Jun 2013
Perhaps if you used getframe() and saved that? With saveas() you are probably getting higher resolution
See Also
Categories
Find more on Printing and Saving 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!