swagat patnaik
swagat patnaik

Reputation: 11

Matlab Figure Error

From past few days I have been getting this awful looking figure while saving a matlab plot. See this: Example

Does anybody have any idea why it is such a case?

This the code for plotting which I am using:

plot(x,y,'o','MarkerSize',7,'MarkerFaceColor',[0.8 0.8 
0.8],'MarkerEdgeColor',[0 0 0]);
[myfit,gof,output] = fit(x,y,'poly1');
hold on
myfitplot = plot(myfit);
set(myfitplot,'Color','k')
set(gca,'FontName','Calibri');
set(gca, 'FontSize',11);
set(gca, 'XTick',[ 0.5,0.52, 0.54])
set(gca, 'YTick',[ 0.48 ,0.54,0.6])
%set(gca, 'XLim',[0.45, 0.6])
%set(gca,'Ylim',[0.45, 0.6])
xlabel('\it{CI_{ETn}}','FontName', 'Calibri','FontSize',15,'FontWeight','b');
ylabel('\it{CI_{GPP}}','FontName', 'Calibri','FontSize',15,'FontWeight','b');
txt = strcat({'\it{R^2 = }'},'\rm',num2str(gof.rsquare,'%.2f'),',',...
' \it{p-val < }','\rm',num2str(0.05,'%.2f'));
lgd = legend(txt);
set(lgd,'FontSize',12);
lgd.Location = 'NorthWest';
hold off

I am guessing some problem with windows? Because I used to get good plots beforehand. Thanks in advance..:)

Edit 1: I am creating the file clicking the export icon. Edit 2: Tried reinstalling matlab, still getting the same results

Edit 3: Final solution that worked is I changed the fonts to 'Times New Roman'. Now the figure outputs are correct..:)

Upvotes: 0

Views: 94

Answers (1)

heriantolim
heriantolim

Reputation: 457

For best results, always use saveas to save as MATLAB figures or print to save as images.

figHandle=figure(...);
axes(...);
plot(...);
plot(...);

saveas(figHandle,filePath1);
print(figHandle,'-dpng','-r300',filePath2);

Upvotes: 0

Related Questions