Weird line to the right of box after saving the plot

2 次查看(过去 30 天)
I was plotting a graph and saved it to jpg using saveas
I used xlim to limit the range of x axis, but there are some line remain on the graph to the right of the graph.
This didn't show up in the figure box of MATLAB
but shows in the jpg file I save
please help me, thank you!
Here's the code I use
subplot(2,2,4)
yyaxis left
h(1) = plot(t_vec,Chiller_RAC_Load_Tons*3.5168525,'LineWidth',1);
hold on
ylabel('Chiller Power [kW]')
xlabel('Time')
yyaxis right
h(2) = plot(t_vec,Ptotal,'LineWidth',1);%Plotting HVAC Power
xlabel('Time')
ylabel('Fan Power [kW]')
title(sprintf('Chiller Power and Fan Power %s/%s/%d',Month_str,Date_str,Year))
hold on;
xline(E1_start,'LineWidth',1,'Color','black')
xline(E1_end,'LineWidth',1,'Color','black')
xline(E2_start,'LineWidth',1,'Color','black')
xline(E2_end,'LineWidth',1,'Color','black')
%legend(h(1:2),'Chiller Power','Fan Power')
xlim([5 20]);
xticks([7 9 11 13 15 17 19 21 23])
xticklabels({'7:00','9:00','11:00','13:00','15:00','17:00','19:00','21:00','23:00'})
set(gca, 'FontSize', 10);
saveas(gcf,sprintf('Chiller Tonnage and Fan Power %s-%d-%d.jpg',Month_str,Date,Year))
  3 个评论
Han Lee
Han Lee 2019-7-23
Thank you for your reply!Clipping didn't work, instead I switch the left two pictures with right two pictures and the lines disappeared.
Adam Danz
Adam Danz 2019-7-23
编辑:Adam Danz 2019-7-23
Hmmm it must have been a quark with the double axes. Glad you found a work around.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by