How to make nice plots?
367 views (last 30 days)
Show older comments
Hello
Will plot in Matlab with the following code.
a = [1.23, 2.34, 5.55, 7, 13.21, 15.66, 18, 20]
x = 1:size(a);
figure('Name', 'Simple plot', 'NumberTitle', 'off');
plot(x, a, '-o');
xlabel('test');
ylabel('test');
I would like to include the plot in a paper which I'm writing, i.e. it should look really nice.
How can I make the plot looking better with Matlab?
Accepted Answer
Kelly Kearney
on 9 Jun 2014
I suppose everyone will have their own preferences for what looks "really nice". I use pdflatex to write most of my articles, and yes, I include figures via \includegrapics. There are some Matlab packages on the FEX to export figures to programatic latex graphics (e.g. TikZ), but most journals I've worked with prefer or require separate graphics files in the more common .png, .pdf, .eps, .jpeg, etc. format.
Some tips I use for getting nice, professional-looking graphics:
2) Make sure your figures, and everything in them, are properly-sized for the paper before exporting. Export using an appropriate resolution (at least 150 dpi, 300 dpi if file size doesn't prohibit it).
3) I usually change the fonts for all axis labels, titles, etc. (and sometimes the tick labels themselves, if they're not too small) to a serif font to match the rest of the text in the paper.
4) Don't rely on the default jet colormap. In addition to the fact rainbow colormaps are almost always a poor choice for visualizing data, I find that published figures that rely on it (and in my field, there are a lot of them) scream "I used Matlab and am lazy!" That's just a personal opinion, of course, but it just doesn't look very professional to me.
10 Comments
Star Strider
on 16 Jun 2014
For those brilliant enough to write an article of sufficient excellence to submit to Science, its guidelines are Science: Information for Authors and Preparing Your Manuscript and Figures.
More Answers (5)
Star Strider
on 9 Jun 2014
I can’t help with LaTeX, but I added a tag to your question so someone with the appropriate knowledge of LaTeX will see it.
The plot part simply requires that you plot two identical values for x and then use the two-element vector ylim (that MATLAB calculates as the y-axis limits for the plot) to define the y-coordinates of the line. That creates the vertical line from the lower to the upper y-limits of the plot, and changes dynamically if you change the data or y-axis limits in your plot.
The code:
a = [1.23, 2.34, 5.55, 7, 13.21, 15.66, 18, 20];
x = 1:size(a,2);
figure('Name', 'Simple plot', 'NumberTitle', 'off');
h=plot(x, a, '-o');
hold on % Plot additional information
plot(x(3), a(3), 'pr') % Plot the point in red
plot([x(3); x(3)], ylim, '-r') % Plot the vertical line in red
hold off % Stop adding plotted data
xlabel('test');
ylabel('test');
I arbitrarily chose x(3) and a(3). Make the appropriate changes to plot the point you want.
0 Comments
Image Analyst
on 11 Jun 2014
You might try Waterloo: http://www.mathworks.com/matlabcentral/answers/56890-publication-quality-graphics-in-matlab
1 Comment
Malcolm Lidierth
on 11 Jun 2014
Thanks for another plug IA.
Although it will not run in MATLAB yet (it requires Java 8+), there is a new version of Waterloo on the way: waterlooFX uses pure JavaFX and many Java 8 features (e.g. streams, lazy evaluation etc).
A pre-release snapshot with demo is available at:
Installers for the demo with an embedded Java 8 is available for win64 and MacOS platforms.
ML
Henric Rydén
on 9 Jun 2014
You can use the hidden LineSmoothing property. Something like this:
a = [1.23, 2.34, 5.55, 7, 13.21, 15.66, 18, 20]
x = 1:size(a,2);
figure('Name', 'Simple plot', 'NumberTitle', 'off');
h=plot(x, a, '-o');
xlabel('test');
ylabel('test');
set(h,'LineSmoothing','On')
0 Comments
Joshua Hrisko
on 16 Feb 2018
Edited: Joshua Hrisko
on 16 Feb 2018
I recommend using a function to improve the visuals of every plot, that way you can call the function and get quality plots each time. Try calling a function similar to the one below (based on my tutorial, found at Publication-Quality Plots - Engineer's Portal) :
function [fig1,ax1,dcm_obj] = fig_open()
set(0,'defaultfigurecolor',[1 1 1]) % white background
set(0,'defaultaxesfontname','cambria math') % beautify the axes a bit
scrn_size = get(0,'ScreenSize'); % get size of screen
shrink_pct = 0.1; % shrink the figure by 10%
%
fig1 = figure('Visible','off','DefaultAxesFontSize',20,'Position',...
[scrn_size(1)+(scrn_size(3)*shrink_pct) scrn_size(2)+(scrn_size(4)*shrink_pct)...
scrn_size(3)-(scrn_size(3)*2*shrink_pct) scrn_size(4)-(scrn_size(4)*2*shrink_pct)]); % shrinking the figure
%
ax1 = gca;
dcm_obj = datacursormode(fig1); % enable control of datatips
% set(dcm_obj,'UpdateFcn',@myupdatefcn) % this will be used to configure
% data tips
set(ax1,'fontsize',22,'Color',[0.8 0.8 0.8],'gridcolor',[1 1 1],'gridalpha',0.9) % set the axis color
% to compliment the white background
%
xlabel('Time [Day HH:MM]') % x-axis date label
hold all
grid on % grid for more contrast in the axes
end
I wrote a blog on how to produce beautiful plots in MATLAB. Check it out here:
%
0 Comments
atharva aalok
on 17 Oct 2021
Edited: atharva aalok
on 17 Oct 2021
Please refer the following Plotting Template:
The above is an easy to follow Beginner Friendly template.
The idea is to create Professional Standard Plots within seconds without a steep learning curve and with consistency.
It also offers a wide range of preset Color Codes (please refer the attached image for the Color Palatte)
Sample Plot:

Color Palatte:

3 Comments
Image Analyst
on 18 Oct 2021
Not true? Hmmm... interesting. So given the learning curves below (a steep one and a flatter one):

you'd prefer the flatter red one where less is learned over time, instead of the steep green one where much more is learned over the same period of time. OK, well whatever. Personally I would prefer the steeper curve, meaning I learned faster and learned more in the same period of time.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!