Last active
May 31, 2016 16:29
-
-
Save ngoldbaum/67cf464cc1e2763f95808759423943d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.figure | |
from matplotlib.font_manager import FontProperties | |
from matplotlib.backends.backend_agg import FigureCanvasAgg | |
font_path = matplotlib.get_data_path() + '/fonts/ttf/STIXGeneral.ttf' | |
fp = FontProperties(**{'fname': font_path, 'size': 18}) | |
fig = matplotlib.figure.Figure() | |
ax = fig.add_axes([0.1, 0.2, 0.8, 0.7]) | |
im = ax.imshow(np.random.random((800, 800))) | |
cb = fig.colorbar(im) | |
cbax = cb.ax | |
ax.set_xlabel('x label') | |
ax.set_ylabel(r'$y\ label$') | |
cb.set_label('colorbar label') | |
labels = ax.xaxis.get_ticklabels() + ax.yaxis.get_ticklabels() | |
labels += cbax.yaxis.get_ticklabels() | |
labels += [ax.title, ax.xaxis.label, ax.yaxis.label, | |
cbax.yaxis.label, cbax.yaxis.get_offset_text(), | |
ax.xaxis.get_offset_text(), ax.yaxis.get_offset_text()] | |
for label in labels: | |
label.set_fontproperties(fp) | |
canvas = FigureCanvasAgg(fig) | |
canvas.print_figure('test.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment