Print a Figure with two Y-Axes - displaced coordinate systems
1 次查看(过去 30 天)
显示 更早的评论
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
and it looks like: http://img705.imageshack.us/img705/6195/figurepreview.jpg and after printing: http://img52.imageshack.us/img52/8356/figureprinted.jpg
4 个评论
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 ...
回答(1 个)
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 个评论
Liviu Ivanescu
2013-11-27
This works if you print from command line, like Titus Edelhofer said! Thanks for the hint Patrick!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two y-axis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!