Weird line to the right of box after saving the plot
3 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!