Skip to content

Instantly share code, notes, and snippets.

@lpillmann
Last active July 13, 2020 20:56
Show Gist options
  • Save lpillmann/1228e6251113f89d02bb2660e5fb2e3d to your computer and use it in GitHub Desktop.
Save lpillmann/1228e6251113f89d02bb2660e5fb2e3d to your computer and use it in GitHub Desktop.
Custom Matplotlib setup to make charts readable, to use with pandas
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
# Heuristics to make labels always readable, for dpi = 100 (default)
fig_w, fig_h = 10, 6 # Figure dimensions (in inches)
font_size = fig_w + fig_h # Font size (in pts.)
matplotlib.rcParams.update({
'figure.figsize': (fig_w, fig_h),
'font.size': font_size,
'font.family': 'monospace', # Optional (default: sans-serif)
'figure.facecolor': 'white', # White background behind ticks (avoid Chrome's black background issue)
#'xtick.labelsize': 'medium', # Adjust relative label sizes
#'ytick.labelsize': 'medium',
#'legend.fontsize': 'medium',
#'legend.framealpha': 1.0
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment