User Tools

Site Tools


figures

Rules for Figures

Pyplot

Matlab

Colours and Greyscale

Relevant Help: http://www.mathworks.com/help/techdoc/ref/colorspec.html

In Matlab, colours are defined as:

color( [ R G B ] )

Using two colours

set( h1, 'Color', [ 0 0 0.5 ] );
set( h2, 'Color', [ 1 0 1 ] );

produces

ColorSpec Colour Greyscale Equivalent
[ 0.0 0.0 0.5 ] Dark Blue Dark Grey
[ 1.0 0.0 1.0 ] Magenta Light Grey

My Default Prettyness

Important:

  • Scale font sizes to figure/panel size
  • Rescale figure before changing axis
  • Set axis, limits, and scale before switching to decimals in loglog

% ---------------------------
% Labels, Titles, Annotations
% ---------------------------
hXLabel = xlabel('$$R/R_d$$', 'Interpreter', 'latex', ...
  'Units', 'normalized', ...
  'Position', [ 0.5 -0.1 ] );
hYLabel = ylabel('$$\Sigma$$ [M$$_{\odot}$$/pc$$^2$$]', 'Interpreter', ...
  'latex', 'Rotation', 0, 'Units', 'normalized', ...
  'Position', [ -0.25 0.5 ] );
hTitle = title( '' );
hText = text();

% -----
% Fonts
% -----
set( gca, 'FontName', 'Helvetica' );
set( [ hTitle, hXLabel, hYLabel ], 'FontName', 'AvantGarde');
set( gca, 'FontSize', 12 );
% set( gca, 'FontSize', 14 );
%   set( hLegend, 'FontSize', 16 );
set( [ hXLabel, hYLabel ] , 'FontSize', 16 );
% set( [ hXLabel, hYLabel ] , 'FontSize', 20 );
set( hTitle, 'FontSize', 16, 'FontWeight' , 'bold' );

% -------
% Details
% -------
set( gca, 'Box', 'on' );
set( gca, 'TickDir', 'in' );
set( gca, 'TickLength', [ .02 0.02 ] );
set( gca, 'XMinorTick', 'on' );
set( gca, 'YMinorTick', 'on' );
set( gca, 'XGrid', 'off' );
set( gca, 'YGrid', 'off' );
set( gca, 'XColor', [ .3 .3 .3 ] );
set( gca, 'YColor', [ .3 .3 .3 ] );
set( gca, 'LineWidth', 0.5 );
set( gca, 'Layer', 'top' );

% -------------------
% Scale, Limits, Axis
% -------------------
set( gca, 'xscale', 'lin' );
set( gca, 'yscale', 'log' );
% xlim( [ 0.01 100 ] );
% ylim( [ 0.01 100 ] );
axis tight;

% ------------
% Rescale Plot
% ------------
% plotRescaleVert( 0.8 );
% plotRescaleHorz( 0.8 );

% ------------------
% Nice LogLog Labels
% ------------------
ytic=get(gca,'YTick'); % Grab the y tick values
yticlab=num2str(ytic'); % Convert to string mx
set(gca,'YTickLabel',yticlab) % Re-label

% xtic=get(gca,'XTick'); % Grab the x tick values
% xticlab=num2str(xtic'); % Convert to string mx
% set(gca,'XTickLabel',xticlab) % Re-label

% ------
% Legend
% ------
hLeg = legend( [ hPlot_HI(2) hPlot_H2(2) ], ...
  { 'H$$\textsc{i}$$', 'H$$_2$$' } );
% hLeg = legend( [ hPlot_HI(2) hPlot_H2(2) hPlot_Star(2) ], ...
%   { 'H$$\textsc{i}$$', 'H$$_2$$', 'Stars' } );
set( hLeg, 'FontSize', 16 );
% set( hLeg, 'FontSize', 20 );
set( hLeg, 'FontName', 'AvantGarde');
set( hLeg, 'Interpreter', 'latex' );
set( hLeg, 'Location', 'Best' );

figures.txt · Last modified: 2013/07/10 07:02 (external edit)