figure "Print Preview" is different as print() figure to file

1 view (last 30 days)
I changed to Matlab R2014b and now the code below is not working anymore. With the help of setappdata() I defined a header “This is a test.” on my page. Unfortunately if I do print the figure to a file this header is missing. If I use the "Print Preview…" option within the GUI, the header will be displayed and also printed to the paper. What has changed within Matlab R2014b that this is not working anymore? Your help is much appreciated. BR, Matthias
figure;
set(gcf,'PaperType', 'A4');
set(gcf,'PaperOrientation', 'portrait');
set(gcf,'PaperPositionMode','manual')
set(gcf,'PaperPosition',[0 1 22 26])
hs = getappdata(gcf,'PrintHeaderHeaderSpec');
if isempty(hs)
hs = struct('dateformat','dd-mmm-yyyy',...
'string','',...
'fontname','Arial',...
'fontsize',12,... % in points
'fontweight','bold',...
'fontangle','normal',...
'margin',72); % in points
end
hs.string = 'This is a test.';
setappdata(gcf,'PrintHeaderHeaderSpec',hs);
print(gcf,'-append','-dpsc','temp.ps');

Accepted Answer

Matthias Taubert
Matthias Taubert on 17 Apr 2015
Edited: Matthias Taubert on 17 Apr 2015
Hello everyone,
just an example of a possible workaround. The code I received from matlab support.
x = linspace(0,10);
y1 = sin(x);
y2 = sin(5*x);
figure
subplot(2,1,1);
plot(x,y1)
title({' ';' ';'Plot 1'}) %We leave space for the figure header.
subplot(2,1,2);
plot(x,y2)
title('Plot 2')
set(gcf,'NextPlot','add');
axes;
h = title('Figure Header');
set(gca,'Visible','off');
set(h,'Visible','on');
BR, Matthias

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!