This notebook is intended to be run by other notebooks through the %run ipython magic. The running notebook will then be styled nicely, have the most common pyparty imports, have pre-set figure size and plotting backend (svg), and will suppress logging in certain cases.
Figure style should be updated later based on Damon McDougall's blog to reflect journal latex templates (see Related).
%pylab inline
Populating the interactive namespace from numpy and matplotlib
JOURNAL_TEXT = 9
# Plotting
LABELSIZE = JOURNAL_TEXT +1 #All plot text except legends (recommed JT -1)
LEGENDSIZE = LABELSIZE * 1.2
# Notebook Style (pyparty style, path or url to .css or None)
NBSTYLE = 'gwu'
# Logging
HIDE_LOG = True
from __future__ import division
# ADD skspec STUFF
#from pyparty import Canvas, splot, showim
if NBSTYLE:
from skspec.bundled import load_style
load_style(NBSTYLE);
You can find the matplotlibrc file path via:
.. >>> matplotlib.matplotlib_fname()
The computer modern font setting is default, so I am happy with it; however, changing the font as done in the commented block below seems to be buggy in the notebook. I can't change the font or its weight, but the size does seem to change correctly...
Caveats:
from matplotlib import rcParams
# # Figure/lines
rcParams['figure.figsize'] = (7.3, 4.2) # SET THIS BASED ON LATEX CONSDIERATIONS LATER!
rcParams['lines.linewidth'] = 2.0
#rcParams['figure.facecolor'] = '0.7' #Plot border, doesn't work
# Plot itself
#rcParams['axes.facecolor'] = '0.75' # Gray background
#rcParams['grid.color'] = 'white' # grid color
#Grid
#rcParams['axes.grid'] = True # display grid or not (has no effect)
# # Labels
rcParams['axes.labelsize'] = LABELSIZE
rcParams['xtick.labelsize'] = LABELSIZE
rcParams['ytick.labelsize'] = LABELSIZE
# # Colors
#rcParams['axes.facecolor'] = (1,0,0) #Same as ipython notebook
# # Legend
rcParams['legend.loc'] = 'upper right'
rcParams['legend.fontsize'] = LEGENDSIZE
rcParams['legend.fancybox'] = True
rcParams['legend.scatterpoints'] = 1 # Draw one scatter point in legend
rcParams['legend.markerscale'] = 1.5 # But make it large
# # Font and text
rcParams['font.family'] = 'serif'
rcParams['font.serif'] = ['Computer Modern'] # Also used by latex (this is default already)
#rcParams['font.weight'] = 'bold' # These don't work
#rcParams['font.style'] = 'oblique'
rcParams['font.size'] = LABELSIZE #Matplotlib title, labels
# Text and latex
rcParams['text.usetex'] = False # Slight differce in how math symbols; as well as text labeled
rcParams['text.color'] = 'black'
# # Image
rcParams['image.cmap'] = 'jet' #Default colormap for 1-channel images/contours
# #Saving
rcParams['savefig.dpi'] = 200
rcParams['savefig.format'] = 'png'
rcParams['savefig.bbox'] = 'tight' #or standard
%config InlineBackend.figure_format = 'svg'
if HIDE_LOG:
import warnings #supress non-pyparty log msgs
warnings.filterwarnings('ignore')
Used in calls to plotly.iplot_mplot(update=_pyudpate)
_pyupdate = dict(
layout =
dict(
# showlegend = False,
font = dict(size=JOURNAL_TEXT),
plot_bgcolor='rgb(191,191,191)' #roughly .75 of 255
),
)