George
George

Reputation: 81

How can I make my plots look prettier (including fonts, label, etc )?

I am trying to obtain very nice plots for my presentation below is a code that I used to plot

clear all 
clc
close all
syms v   
omegat= -2:0.000001:2;

Nt=32;
gainfuc = (1/Nt)*exp(1i*pi*omegat*(Nt-1)/2).*sin(pi*Nt*omegat/2)./sin(pi*omegat/2);
gainfuc(omegat == 0) = 1;
G = (omegat < 2/Nt).*(omegat > -2/Nt);
plot(omegat,abs(gainfuc))
syms t
hold on
grid on
plot(omegat,G,'r')
ylabel('G_t(y)','FontSize',16,'FontWeight','bold')
xlabel('y','FontSize',16,'FontWeight','bold')

My question is quite simple, any ideas to make this plot nicer (font, grids, etc...) so that it would look nice in presentations?

Update I have obtained the following figure after the changes recommended in the answer below enter image description here

Upvotes: 0

Views: 592

Answers (1)

Robert Seifert
Robert Seifert

Reputation: 25232

In Matlab 2014b a new graphic engine got introduced, it immediately looks more pretty.

New default colormap presents data more accurately, making it easier to interpret. New default line colors, fonts, and styles with anti-aliased graphics and fonts improve the clarity and aesthetics of MATLAB visualizations.

In Matlab 2014a you can also activate the new graphics engine by following these instructions.

In earlier versions the hack is may also possible, but I haven't tested it. It is most likely quite buggy. For 2014a I use it for almost a year now and it works like a charm. I couldn't find any differences to the final release of HG2 in 2014b.


Make sure that smoothing is set to 'on'

h = gcf;
h.GraphicsSmoothing = 'on'

enter image description here

I also used the standard LateX font CMU Serif Roman to spice everything up. Enter this lines at the beginning of your code after installing the fonts (open source).

set(0,'defaultAxesFontName', 'CMU Serif Roman')
set(0,'defaultAxesFontSize', 12)

General recommendations:

  • Use vector graphic renders: set(gcf, 'renderer', 'painters')
  • Specify the resolution when saving your plots, especially for pixel graphics: print('-dpng','-r600','PeaksSurface') (still use the vector renderer!)
  • The vector format for MS Office is .emf and is also supported by Matlab
  • May use: set(gcf,'InvertHardcopy','off')

Upvotes: 4

Related Questions