You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# http://jonathansoma.com/lede/data-studio/matplotlib/list-all-fonts-available-in-matplotlib-plus-samples/# List all fonts available in matplotlib plus samplesimportmatplotlib.font_managerfromIPython.core.displayimportHTMLdefmake_html(fontname):
return"<p>{font}: <span style='font-family:{font}; font-size: 24px;'>{font}</p>".format(font=fontname)
code="\n".join([make_html(font) forfontinsorted(set([f.nameforfinmatplotlib.font_manager.fontManager.ttflist]))])
HTML("<div style='column-count: 2;'>{}</div>".format(code))
fromIPython.displayimportset_matplotlib_formats#%matplotlib inlineset_matplotlib_formats('svg') # use SVG backend to maintain vectorizationplt.style.use('default') #reset default parameters# https://stackoverflow.com/a/3900167/446907plt.rcParams.update({'font.size': 16,
'font.family': ['sans-serif'],
'font.serif': ['Latin Modern Roman'] +plt.rcParams['font.serif'],
'font.sans-serif': ['Latin Modern Sans'] +plt.rcParams['font.sans-serif']})
Check rcParams after update and list fonts available to matplotlib
# plt.rcParams.values# code = "\n".join([make_html(font) for font in sorted(set([f.name for f in matplotlib.font_manager.fontManager.ttflist]))])# HTML("<div style='column-count: 2;'>{}</div>".format(code))
Create a test plot
# import numpy as np# t = np.arange(-1.0, 2.0, 0.01)# s = 1 + np.sin(2 * np.pi * t)# fig, ax = plt.subplots()# ax.plot(t, s)# ax.set(xlabel='time (s)', ylabel='voltage (mV)',# title='About as simple as it gets, folks')# ax.grid()# plt.savefig("fig/test-plot.svg", bbox_inches="tight");# !inkscape fig/test-plot.svg --export-filename=fig/test-plot.pdf;