Print a Figure with two Y-Axes - displaced coordinate systems

조회 수: 4 (최근 30일)
Fabian
Fabian 2012년 1월 4일
댓글: Liviu Ivanescu 2013년 11월 27일
I got o problem with a figure where there are two Y-Axes. When I am in the print preview layout, I can see the coordinate system fitting well.
However, when I do print the figure, two coordinate systems are appearing and they are shifted, and the labels, ticks and curves are not matching any more. It looks like these coordinate systems are displaced, which has not appeared in the print preview.
Is there a way to fix it?
I am basically using this code:
figure(3)
% Plot V Nits and Temp Black Body with two Y-Axes
[AX,H1,H2] = plotyy(x,v_original,x,t_bb);
% Set Axis names & Grid on
% left Y-Axis
% set label
set(get(AX(1),'Ylabel'),'String','U_A [\mu V]', 'Color', 'black')
% set Axis values
set(AX(1),'YLim', [-50000 50000], 'YTick', -50000:10000:50000);
% right Y-Axis
% set label
set(get(AX(2),'Ylabel'),'String','Temperature[°C]', 'Color', 'black')
% set Axis values
set(AX(2),'YLim', [-50 50],'YTick', -50:5:50);
grid on;
% Set Curves color
% for V_original = Voltage THERMOPILE
set(H1,'Color',[0 0 0], 'LineStyle', '-');
% for T_bb = Temperature Blackbody
set(H2,'Color','red', 'LineStyle', '--', 'LineWidth', 2);
hold on
% mean values
H3 = bar(x,v_mean);
set(H3,'FaceColor',[.96 .92 .92], 'EdgeColor','none');
% median values
H4 = bar(x,v_median);
set(H4,'FaceColor',[.89 .94 .9], 'EdgeColor','none');
% standard deviation
H5 = bar(x,v_sd);
set(H5,'FaceColor',[.87 .92 .98], 'EdgeColor','none');
% Enable 2nd Y-Axis so multiple plots can be drawn
% depending on that scale
set(AX(2),'nextplot','add');
% temperature NITS
H6 = plot(AX(2),x, t_nits);
set(H6,'Color','green', 'LineStyle', '--', 'LineWidth', 2);
% Enable 2nd Y-Axis so multiple plots can be drawn
% depending on that scale
set(AX(2),'nextplot','add');
% temperature Amb
H7 = plot(AX(2),x, t_amb);
set(H7,'Color','blue', 'LineStyle', '--', 'LineWidth', 2);
title('T_A_m_b = -5°C');
xlabel('Zeit \tau in [s]');
legend('V_A', 'V_M_e_a_n', 'V_M_e_d_i_a_n', 'V_S_t_a_n_d_a_r_d', 'T_B_B', 'T_n_i_t_s', 'T_a_m_b', 'location', 'NorthWest');
hold off
  댓글 수: 4
Titus Edelhofer
Titus Edelhofer 2012년 1월 5일
How do you print? Simply "print -djpeg figureprinted.jpg"? I ran your code with some data and got a nice result ...
Fabian
Fabian 2012년 1월 5일
I am printing via the interactive Menu:
File - Print Preview - Print
I have already tried if the Orientation, the paper style or something else matters - unfortunately I always end up in the same result with the displaced coordinate systems.

댓글을 달려면 로그인하십시오.

답변 (1개)

Patrick Kalita
Patrick Kalita 2012년 1월 4일
This is just a guess, but you could try doing this at the end of your code:
set(AX, 'ActivePositionProperty', 'position');
where AX is the array hold the two axes handles.
  댓글 수: 2
Fabian
Fabian 2012년 1월 5일
unfortunately, that is not working.
Liviu Ivanescu
Liviu Ivanescu 2013년 11월 27일
This works if you print from command line, like Titus Edelhofer said! Thanks for the hint Patrick!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by