Rendering error - print large size pdf

28 vues (au cours des 30 derniers jours)
TP
TP le 30 Avr 2019
Modifié(e) : TP le 27 Jan 2020
Edit: The code works with Matlab 2015b but but produces the described error with Matlab 2018b (Windows 7).
I am trying to print a large size pdf (A2) containing vector elements on top of a simple imagesc (see minimal example below). The code works when printing the figure as a raster, but not when printing as a vector (see error message below). I do not mind if the "imagesc" is saved in a raster format, but I would like to keep the overlaying lines and axes in vector format. Is there a BUILT-IN solution for this problem?
Minimal (non-)working example:
clear all; close all; clc
dx_figure=59.4; dy_figure=42; % A2 landscape format in centimeters (cm)
margin=2.5; % in cm; allow for margin between axes and figure
f_handle=figure;
set(f_handle,'visible','off'); % make figure invisible on screen to avoid automatic resizing
set(f_handle,'units','centimeters','position',[0 0 dx_figure dy_figure]); % set figure at true size
axes('position',[margin/dx_figure margin/dy_figure (dx_figure-2*margin)/dx_figure (dy_figure-2*margin)/dy_figure]) % create axes in normalized units (bug when working in cm)
imagesc(rand(10,10)); % when this line is commented out, the figure is successfully printed in both raster or vector format
hold on
plot([0 10],[0 10],'linewidth',5); % vector part of figure
set(f_handle,'paperunits','centimeters','paperpositionmode','manual','papersize',[dx_figure dy_figure],'paperposition',[0 0 dx_figure dy_figure]);
print(f_handle,'-dpdf','image_vector'); % print in vector format (does not work)
%print(f_handle,'-dpdf','image_raster','-opengl'); % print in raster format (works)
Error message:
Warning: An error occurred while drawing the scene: Unidentified trouble during rendering
> In defaulterrorcallback (line 12)
In matlab.graphics.internal.mlprintjob/setPaintDisabled
In alternatePrintPath
In alternatePrintPath
In onCleanup/delete (line 60)
In alternatePrintPath
In print (line 82)
  1 commentaire
Anders Svensson
Anders Svensson le 31 Août 2019
I have a very similar problem. A code that worke perfect in 2015b experience the described problem in 2017b. To mee the error is a bit random. It does not happen all the time. Running the same script with the same input generates the error on approximately 20% of my 2D plots. It appears as if the error is more frequent on larger images.

Connectez-vous pour commenter.

Réponses (1)

Luis J Gilarranz
Luis J Gilarranz le 25 Jan 2020
Maybe this helps ;-)
Let us know, if using
opengl software
as suggested in this question solves the problem, Mathworks should consider this as a bug.
  1 commentaire
TP
TP le 27 Jan 2020
Modifié(e) : TP le 27 Jan 2020
Thanks, I just tried but it does not change the problem.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by