Matplotlib can be customized to make beautiful graphs, but the settings that it has out-of-the-box leave a bit to be desired. The default setting can be changed by editing your matplotlibrc file. A default configuration file is located in site-packages/matplotlib/mpl-data/matplotlibrc
(relative to your Python installation location). Do not edit this file, but copy it to one of the following locations:
- unix/linux:
$HOME/.config/matplotlib/matplotlibrc
$XDG_CONFIG_HOME/matplotlib/matplotlibrc
(if $XDG_CONFIG_HOME is set)
- other platforms:
- $HOME/.matplotlib/matplotlibrc
Here are some settings that I have at the top of my copied matplotlibrc file
# This makes figures that give you 1 inch margins on either side of a 8.5" wide paper
figure.figsize : 6.5, 3
# Render figures in the browser with a few more pixels, otherwise your figures are tiny in Jupyter
figure.dpi: 150
# Export figures at print-quality resolution
savefig.dpi: 300
# Font settings
font.sans-serif: Arial # Arial sucks, but the better Helvitica is not a system font and hard to configure on windows
# Make the font big enough for users to actually read. You want fontsize to be similar
# to the text size around the figure, which is 10 to 12 pt in word documents
font.size: 12
savefig.bbox: tight # Reduce superfluous margins
timezone: US/Pacific # Helpful when plotting time series in local instead of UTC
# Edward Tufte says to increase the data-to-ink ratio by eliminating chart junk
# Personal preference, but I find right and top spines to be chart junk
axes.spines.left: True
axes.spines.bottom: True
axes.spines.top: False
axes.spines.right: False
When I was writing scientific journals, I would set the figure size to 3.5 inches wide and 2.625 inches tall. The font size was 8 pt, and I was able to get Helvetica installed on my Mac so that I could render Helvetica. Your mileage may vary.