Rendering error - print large size pdf

25 ビュー (過去 30 日間)
TP
TP 2019 年 4 月 30 日
編集済み: TP 2020 年 1 月 27 日
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 件のコメント
Anders Svensson
Anders Svensson 2019 年 8 月 31 日
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.

サインインしてコメントする。

回答 (1 件)

Luis J Gilarranz
Luis J Gilarranz 2020 年 1 月 25 日
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 件のコメント
TP
TP 2020 年 1 月 27 日
編集済み: TP 2020 年 1 月 27 日
Thanks, I just tried but it does not change the problem.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by