# How to make smart paper ready figures in MATLAB

We currently do a lot of research that is published in various journals or conferences. We need to add many scientific pictures to these research papers. We often make all these pictures using MATLAB software. Using the various functions of MATLAB software, we can make our created images more vivid. Say we have 5 sets of data and we have to plot them in a single frame. Here we can see the before and after figures to realize the differences. Later we will set by step how to create this figure.

A file link that contains all the data to plot this figure is given below.

Initial Code:

% Creating the plot
plot (x,y);
hold on;
plot (x1,y1);
hold on;
plot (x2,y2);
hold on;
plot (x3,y3);

% setting the axis
xlim([0,0.7]);
xticks([0 0.1 0.2 0.3 0.4 0.5 0.6 0.7]);
xticklabels({'0','0.1','0.2','0.3','0.4','0.5','0.6','0.7'});
ylim([0,5]);
yticks([0 1 2 3 4 5]);
yticklabels({'0','1','2','3','4','5'});
xlabel('V(V)');
ylabel('P(W)');

% Grid and legend letup
grid on;
legend();

The above figure is an ordinary figure. Let's make it ready for publication paper through coding.

Modified Code:

% Line plots enhanced width
plot (x,y,'LineWidth',3);
hold on;
plot (x1,y1,'LineWidth',3);
hold on;
plot (x2,y2,'LineWidth',3);
hold on;
plot (x3,y3,'LineWidth',3);

% Setting up axis as before
xlim([0,0.7]);
xticks([0 0.1 0.2 0.3 0.4 0.5 0.6 0.7]);
xticklabels({'0','0.1','0.2','0.3','0.4','0.5','0.6','0.7'});
ylim([0,5]);
yticks([0 1 2 3 4 5]);
yticklabels({'0','1','2','3','4','5'});

% Customaing texts in the axis
xlabel('V(V)','FontName','Arial','fontsize',20);
ylabel('P(W)','FontName','Arial','fontsize',20);
grid off;
box off;

legend ('75^{o}C','50^{o}C','25^{o}C','0^{o}C','location','northwest');
legend boxoff;

Now let's try to make some cosmetic changes to make it even better.

Smart Code:

% Plot creation and axis setup
plot (x,y,'LineWidth',3);
hold on;
plot (x1,y1,'LineWidth',3);
hold on;
plot (x2,y2,'LineWidth',3);
hold on;
plot (x3,y3,'LineWidth',3);
xlim([0,0.7]);
xticks([0 0.1 0.2 0.3 0.4 0.5 0.6 0.7]);
xticklabels({'0','0.1','0.2','0.3','0.4','0.5','0.6','0.7'});
ylim([0,5]);
yticks([0 1 2 3 4 5]);
yticklabels({'0','1','2','3','4','5'});

% Axis and legend setup
xlabel('V(V)','FontName','Arial','fontsize',20);
ylabel('P(W)','FontName','Arial','fontsize',20);
grid off;
box off;
legend ('75^{o}C','50^{o}C','25^{o}C','0^{o}C','location','northwest');
legend boxoff;

% Removing tick to make it look more profession
set(gca, 'Ticklength', [0 0])

% Customizing texts in the axis in ticklabel, making the background white
set(gcf,'color','w');
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'FontName','Arial','fontsize',15);
b = get(gca,'YTickLabel');
set(gca,'YTickLabel',b,'FontName','Arial','fontsize',15);

% Fixing the aspect ratio
pbaspect([8,6,1])

To export the figure in the right way is very important!!

Here is the way you can do it professionally using 'exportfig' toolbox

% Capturing the frame with vector information
ha = axes('Position',[0 0 1 1],'Xlim',[0 1],'Ylim',[0 1],'Box','off','Visible','off','Units','normalized', 'clipping' , 'on');
set(gcf,'PaperPositionMode','auto')

% Saving the figure as png. In the toolbox there are options to export as vector graphics as well.
export_fig([cd filesep 'Blogfig' '_F'],'-a2', '-m4','-p0.01','-png', '-r300');

Here you go. All set!. Hope it helps. Let us know what you think in the comment box :)