exportgraphics: need error explained

21 views (last 30 days)
millercommamatt
millercommamatt on 19 Jun 2020
Commented: millercommamatt on 25 Jun 2020
I'm trying to export of multi-panel plot that contains 4 imagesc plots and two surf plots with the new exportgraphics command with the vector option.
The command produces the following error:
Warning: Vectorized content might take a long time to create, or it might contain unexpected results. Set 'ContentType' to 'image' for better
performance. Click here to not see this message again.
Warning: An error occurred while drawing the scene: An error occurred while rendering after the depth sort.
In the EPS file that is produced, the axes for the surface plots are empty. The surface mesh just isn't there.
Can someone please explain the error and provide guidance on what I can do to avoid this error and get a successful plot saved?
  4 Comments
millercommamatt
millercommamatt on 22 Jun 2020
This seems to come down to array size.
I took my plotting function, stripped off all the labels and started feeding in random synthetic data to try to figure out what the point were things go wrong was. At some point then the arrays being plotting get big enough, this error about the depth sort comes up.
At this point, I'm going to experiment with plotting the figure panels one-by-one and stitching things together in Illustrator (if the panels will in fact sucessfully save as EPS). However, if anyone has any guidance on ameliorating this issue, I'm all ears.
Here's some test code. On my machine, the saving will eventually throw an error in the arrays get big. In this case and on my machine (i7-10710 U, 16 GB RAM) upping the array sizes by a factor of 5-10 per dimension seems to be enough to do the trick.
%vector plot diagnostic test (this works)
[Az, Rg]=meshgrid(1:360,1:30);
FH=figure('Position',[10 10 1200 1200],'Renderer','painters');
TH=tiledlayout(FH,4,2,'Padding','compact','TileSpacing','compact');
nexttile(1);
imagesc(randi([1 10],50));
nexttile(2);
imagesc(randi([1 10],50));
nexttile(3);
imagesc(randi([1 10],50));
nexttile(4);
imagesc(randi([1 10],50));
nexttile(5,[2 1]);
surf(Rg.*cosd(Az),Rg.*sind(Az),randi([1 10],size(Az)),'EdgeColor','none'); view(2);
hold on;
plot3([0 10],[0 0],[10 10],'k','LineWidth',2);
axis image;
nexttile(6,[2 1]);
surf(Rg.*cosd(Az),Rg.*sind(Az),randi([1 10],size(Az)),'EdgeColor','none'); view(2);
hold on;
plot3([0 10],[0 0],[10 10],'k','LineWidth',2);
axis image;
exportgraphics(FH,'testEPS.eps','ContentType','vector');
%vector plot diagnostic test (this does not work)
[Az, Rg]=meshgrid(1:0.5:360,1:150);
FH=figure('Renderer','painters');
TH=tiledlayout(FH,4,2,'Padding','compact','TileSpacing','compact');
nexttile(1);
imagesc(randi([1 10],200));
nexttile(2);
imagesc(randi([1 10],200));
nexttile(3);
imagesc(randi([1 10],200));
nexttile(4);
imagesc(randi([1 10],200));
nexttile(5,[2 1]);
surf(Rg.*cosd(Az),Rg.*sind(Az),randi([1 10],size(Az)),'EdgeColor','none'); view(2);
hold on;
plot3([0 10],[0 0],[10 10],'k','LineWidth',2);
axis image;
nexttile(6,[2 1]);
surf(Rg.*cosd(Az),Rg.*sind(Az),randi([1 10],size(Az)),'EdgeColor','none'); view(2);
hold on;
plot3([0 50],[0 0],[10 10],'k','LineWidth',2);
axis image;
exportgraphics(FH,'testEPS.eps','ContentType','vector');
Saving as something like a PNG works fine and at no point do I encounter an out-of-memory error.
millercommamatt
millercommamatt on 25 Jun 2020
I've reduced this case to an even simpler example with just a single surf plot.
As the array I try to plot becomes larger, I reach the point where using exportgraphics to save an EPS figure fails with the depth sort error.
Is the error mentioning depth sort telling me anything useful about if they're something going wrong that I can avoid or work around?
I've had to degrade the resolution of the data I'm trying to plot to get things working and that's really not an preferrable outcome.

Sign in to comment.

Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!