How to make nice plots?
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?
2 Comments
Star Strider
on 9 Jun 2014
How do you want it to look?
What do you want to do?
Please go into some detail.
Sepp
on 9 Jun 2014
Accepted Answer
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.
Image Analyst
on 11 Jun 2014
1 vote
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')
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:
%
1 Comment
Daniel DEKASSE
on 14 Sep 2023
atharva aalok
on 17 Oct 2021
Edited: atharva aalok
on 17 Oct 2021
0 votes
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
But people want a steep learning curve. You want amount learned (knowledge gained) vs. time to be as steep as possible. A flat learning curve would mean you don't learn much as time progresses - not what you want.
atharva aalok
on 18 Oct 2021
No that's not true in most cases.
A researcher probably just wants better quality graphs without learning in depth the details of MATLAB.
The learning part is good from a long term perspective but what a beginner probably needs is a quick and easy to understand solution that gets the work done. Otherwise a steep learning curve can actually hinder growth.
Once she knows that certain things can be done then he might be interested in going into the details to customize things as per individual requirement.
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.
Categories
Find more on Data Distribution 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!