This page demonstrates Python tips and tricks that I use in my everyday programming as an atmospheric science graduate student.
-Brian Blaylock

Friday, April 29, 2016

Redefine Matplotlib defaults: Plotting Publication Quality Plots

The default python matplotlib settings don't look too good for publication quality work. So here I redefine some of matplotlib's default settings before I make a plot.

(see other parameters you can modify here: http://matplotlib.org/users/customizing.html)

import matplotlib as mpl

# Specify universal figure sizes acceptable for publication
# J.AtmosEnv
#        Figure width     |   Inches wide       
#   ----------------------+---------------------
#   1/2 page (1 column)   |  3.54 in. ( 90 mm)   
#   3/4 page (1.5 column) |  5.51 in. (140 mm)    
#   1   page (2 column)   |  7.48 in. (190 mm)    
#   ---------------------------------------------
# Image Resolution:  line graphs = 1000 dpi
#                    colorfilled = 500 dpi         
#                    web images  = 72 dpi             

label_font  = 10    
tick_font   = 8 
legend_font = 7

width=3.5
height=3

## Reset the defaults
mpl.rcParams['xtick.labelsize'] = tick_font
mpl.rcParams['ytick.labelsize'] = tick_font
mpl.rcParams['axes.labelsize'] = label_font
mpl.rcParams['legend.fontsize'] = legend_font

mpl.rcParams['figure.figsize'] = [width,height] 

mpl.rcParams['grid.linewidth'] = .25

mpl.rcParams['savefig.bbox'] = 'tight'
mpl.rcParams['savefig.dpi'] = 1000

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.