[yt-svn] commit/yt: 12 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Feb 25 10:54:39 PST 2013
12 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/ad83cd37fbd8/
changeset: ad83cd37fbd8
branch: yt
user: ngoldbaum
date: 2013-02-22 03:26:10
summary: Making tick labels use a serif family font by default. Closes #504.
affected #: 1 file
diff -r 9b309d23df1994ba0a339ac4901b3e29d5f66d9c -r ad83cd37fbd84437bc71c6ce77e25143da87d864 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -32,6 +32,7 @@
import __builtin__
from matplotlib.mathtext import MathTextParser
+from matplotlib.font_manager import FontProperties
from distutils import version
from functools import wraps
@@ -220,10 +221,9 @@
-width[2][0]/pf[units[2]]/2, width[2][0]/pf[units[2]]/2)
return (bounds, center, units)
+
class PlotWindow(object):
r"""
- PlotWindow(data_source, bounds, buff_size=(800,800), antialias = True)
-
A ploting mechanism based around the concept of a window into a
data source. It can have arbitrary fields, each of which will be
centered on the same viewpoint, but will have individual zlimits.
@@ -251,6 +251,8 @@
window_size : float
The size of the window on the longest axis (in units of inches),
including the margins but not the colorbar.
+ fontsize : int
+ The font size of tick and axes labels in points.
"""
_plot_valid = False
@@ -260,7 +262,7 @@
_frb = None
def __init__(self, data_source, bounds, buff_size=(800,800), antialias=True,
periodic=True, origin='center-window', oblique=False, fontsize=15,
- window_size=10.0):
+ window_size=10.0, serif=True):
if not hasattr(self, "pf"):
self.pf = data_source.pf
ts = self._initialize_dataset(self.pf)
@@ -277,8 +279,11 @@
self.set_window(bounds) # this automatically updates the data and plot
self.origin = origin
self.fontsize = fontsize
+ self.serif = serif
+ self.font_properties = None
if self.data_source.center is not None and oblique == False:
- center = [self.data_source.center[i] for i in range(len(self.data_source.center)) if i != self.data_source.axis]
+ center = [self.data_source.center[i] for i in range(len(self.data_source.center))
+ if i != self.data_source.axis]
self.set_center(center)
self._initfinished = True
@@ -802,7 +807,14 @@
if self._plot_type is None:
self._plot_type = kwargs.pop("plot_type")
PWViewer.__init__(self, *args, **kwargs)
-
+ if self.serif:
+ family='serif'
+ else:
+ family='sans-serif'
+ self.font_properties = \
+ FontProperties(family=family, size=self.fontsize)
+
+
def _setup_origin(self):
origin = self.origin
axis_index = self.data_source.axis
@@ -922,10 +934,17 @@
labels = [r'$\rm{'+axis_labels[axis_index][i]+
axes_unit_labels[i] + r'}$' for i in (0,1)]
- self.plots[f].axes.set_xlabel(labels[0],fontsize=self.fontsize)
- self.plots[f].axes.set_ylabel(labels[1],fontsize=self.fontsize)
+ if self.font_properties is None:
+ fp = FontProperties()
+ else:
+ fp = self.font_properties
+
+ self.plots[f].axes.set_xlabel(labels[0],fontproperties=fp)
+ self.plots[f].axes.set_ylabel(labels[1],fontproperties=fp)
- self.plots[f].axes.tick_params(labelsize=self.fontsize)
+ for label in (self.plots[f].axes.get_xticklabels() +
+ self.plots[f].axes.get_yticklabels()):
+ label.set_fontproperties(fp)
colorbar_label = image.info['label']
@@ -935,9 +954,10 @@
except ParseFatalException, err:
raise YTCannotParseUnitDisplayName(f, colorbar_label, str(err))
- self.plots[f].cb.set_label(colorbar_label, fontsize=self.fontsize)
+ self.plots[f].cb.set_label(colorbar_label, fontproperties=fp)
- self.plots[f].cb.ax.tick_params(labelsize=self.fontsize)
+ for label in self.plots[f].cb.ax.get_yticklabels():
+ label.set_fontproperties(fp)
self.run_callbacks(f)
@@ -1137,7 +1157,9 @@
('{yloc}', '{xloc}', '{space}') ('lower', 'right', 'window')
================================== ============================
fontsize : integer
- The size of the fonts for the axis, colorbar, and tick labels.
+ The size of the fonts for the axis, colorbar, and tick labels
+ serif : boolean
+ Determines whether ticks labels are drawn using a serif or sans-serif font.
field_parameters : dictionary
A dictionary of field parameters than can be accessed by derived fields.
@@ -1155,7 +1177,7 @@
_frb_generator = FixedResolutionBuffer
def __init__(self, pf, axis, fields, center='c', width=None, axes_unit=None,
- origin='center-window', fontsize=15, field_parameters=None):
+ origin='center-window', fontsize=15, serif=True, field_parameters=None):
# this will handle time series data and controllers
ts = self._initialize_dataset(pf)
self.ts = ts
@@ -1166,7 +1188,7 @@
axes_unit = units
if field_parameters is None: field_parameters = {}
slc = pf.h.slice(axis, center[axis], center=center, fields=fields, **field_parameters)
- PWViewerMPL.__init__(self, slc, bounds, origin=origin, fontsize=fontsize)
+ PWViewerMPL.__init__(self, slc, bounds, origin=origin, fontsize=fontsize, serif=serif)
self.set_axes_unit(axes_unit)
class ProjectionPlot(PWViewerMPL):
@@ -1253,6 +1275,8 @@
The maximum level to project to.
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
+ serif : boolean
+ Determines whether ticks labels are drawn using a serif or sans-serif font.
field_parameters : dictionary
A dictionary of field parameters than can be accessed by derived fields.
@@ -1271,7 +1295,7 @@
def __init__(self, pf, axis, fields, center='c', width=None, axes_unit=None,
weight_field=None, max_level=None, origin='center-window', fontsize=15,
- field_parameters=None):
+ serif=True, field_parameters=None):
ts = self._initialize_dataset(pf)
self.ts = ts
pf = self.pf = ts[0]
@@ -1280,9 +1304,10 @@
if axes_unit is None and units != ('1', '1'):
axes_unit = units
if field_parameters is None: field_parameters = {}
- proj = pf.h.proj(axis,fields,weight_field=weight_field,max_level=max_level,
+ proj = pf.h.proj(axis, fields, weight_field=weight_field, max_level=max_level,
center=center, **field_parameters)
- PWViewerMPL.__init__(self,proj,bounds,origin=origin,fontsize=fontsize)
+ PWViewerMPL.__init__(self, proj, bounds, origin=origin, fontsize=fontsize,
+ serif=serif)
self.set_axes_unit(axes_unit)
class OffAxisSlicePlot(PWViewerMPL):
@@ -1324,6 +1349,8 @@
set, an arbitrary grid-aligned north-vector is chosen.
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
+ serif : boolean
+ Determines whether ticks labels are drawn using a serif or sans-serif font.
field_parameters : dictionary
A dictionary of field parameters than can be accessed by derived fields.
"""
@@ -1333,7 +1360,7 @@
def __init__(self, pf, normal, fields, center='c', width=None,
axes_unit=None, north_vector=None, fontsize=15,
- field_parameters=None):
+ serif=True, field_parameters=None):
(bounds, center_rot, units) = GetObliqueWindowParameters(normal,center,width,pf)
if axes_unit is None and units != ('1', '1'):
axes_unit = units
@@ -1341,8 +1368,8 @@
cutting = pf.h.cutting(normal, center, fields=fields, north_vector=north_vector, **field_parameters)
# Hard-coding the origin keyword since the other two options
# aren't well-defined for off-axis data objects
- PWViewerMPL.__init__(self,cutting,bounds,origin='center-window',periodic=False,
- oblique=True,fontsize=fontsize)
+ PWViewerMPL.__init__(self, cutting, bounds, origin='center-window', periodic=False,
+ oblique=True, fontsize=fontsize, serif=serif)
self.set_axes_unit(axes_unit)
class OffAxisProjectionDummyDataSource(object):
@@ -1429,6 +1456,10 @@
A vector defining the 'up' direction in the plot. This
option sets the orientation of the slicing plane. If not
set, an arbitrary grid-aligned north-vector is chosen.
+ fontsize : integer
+ The size of the fonts for the axis, colorbar, and tick labels.
+ serif : boolean
+ Determines whether ticks labels are drawn using a serif or sans-serif font.
"""
_plot_type = 'OffAxisProjection'
@@ -1437,7 +1468,7 @@
def __init__(self, pf, normal, fields, center='c', width=None,
depth=(1, '1'), axes_unit=None, weight_field=None,
max_level=None, north_vector=None, volume=None, no_ghost=False,
- le=None, re=None, interpolated=False, fontsize=15):
+ le=None, re=None, interpolated=False, fontsize=15, serif=True):
(bounds, center_rot, units) = GetObliqueWindowParameters(normal,center,width,pf,depth=depth)
if axes_unit is None and units != ('1', '1', '1'):
axes_unit = units[:2]
@@ -1448,8 +1479,8 @@
le=le, re=re, north_vector=north_vector)
# Hard-coding the origin keyword since the other two options
# aren't well-defined for off-axis data objects
- PWViewerMPL.__init__(self,OffAxisProj,bounds,origin='center-window',periodic=False,
- oblique=True,fontsize=fontsize)
+ PWViewerMPL.__init__(self, OffAxisProj, bounds, origin='center-window', periodic=False,
+ oblique=True, fontsize=fontsize, serif=True)
self.set_axes_unit(axes_unit)
_metadata_template = """
https://bitbucket.org/yt_analysis/yt/commits/37a370b33f90/
changeset: 37a370b33f90
branch: yt
user: ngoldbaum
date: 2013-02-22 03:33:49
summary: Bumping the default font size to 18.
affected #: 1 file
diff -r ad83cd37fbd84437bc71c6ce77e25143da87d864 -r 37a370b33f90fe7cdb2810641cd9a00755bb6298 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -261,7 +261,7 @@
_vector_info = None
_frb = None
def __init__(self, data_source, bounds, buff_size=(800,800), antialias=True,
- periodic=True, origin='center-window', oblique=False, fontsize=15,
+ periodic=True, origin='center-window', oblique=False, fontsize=18,
window_size=10.0, serif=True):
if not hasattr(self, "pf"):
self.pf = data_source.pf
@@ -1177,7 +1177,7 @@
_frb_generator = FixedResolutionBuffer
def __init__(self, pf, axis, fields, center='c', width=None, axes_unit=None,
- origin='center-window', fontsize=15, serif=True, field_parameters=None):
+ origin='center-window', fontsize=18, serif=True, field_parameters=None):
# this will handle time series data and controllers
ts = self._initialize_dataset(pf)
self.ts = ts
@@ -1294,7 +1294,7 @@
_frb_generator = FixedResolutionBuffer
def __init__(self, pf, axis, fields, center='c', width=None, axes_unit=None,
- weight_field=None, max_level=None, origin='center-window', fontsize=15,
+ weight_field=None, max_level=None, origin='center-window', fontsize=18,
serif=True, field_parameters=None):
ts = self._initialize_dataset(pf)
self.ts = ts
@@ -1359,7 +1359,7 @@
_frb_generator = ObliqueFixedResolutionBuffer
def __init__(self, pf, normal, fields, center='c', width=None,
- axes_unit=None, north_vector=None, fontsize=15,
+ axes_unit=None, north_vector=None, fontsize=18,
serif=True, field_parameters=None):
(bounds, center_rot, units) = GetObliqueWindowParameters(normal,center,width,pf)
if axes_unit is None and units != ('1', '1'):
@@ -1468,7 +1468,7 @@
def __init__(self, pf, normal, fields, center='c', width=None,
depth=(1, '1'), axes_unit=None, weight_field=None,
max_level=None, north_vector=None, volume=None, no_ghost=False,
- le=None, re=None, interpolated=False, fontsize=15, serif=True):
+ le=None, re=None, interpolated=False, fontsize=18, serif=True):
(bounds, center_rot, units) = GetObliqueWindowParameters(normal,center,width,pf,depth=depth)
if axes_unit is None and units != ('1', '1', '1'):
axes_unit = units[:2]
@@ -1668,9 +1668,9 @@
self._init_image(data, cbname, cmap, extent, aspect)
self.image.axes.ticklabel_format(scilimits=(-2,3))
- def _get_best_layout(self, size, fontsize=15):
+ def _get_best_layout(self, size, fontsize=18):
aspect = 1.0*size[0]/size[1]
- fontscale = fontsize / 15.0
+ fontscale = fontsize / 18.0
# add room for a colorbar
cbar_inches = fontscale*0.7
https://bitbucket.org/yt_analysis/yt/commits/321beb7fd671/
changeset: 321beb7fd671
branch: yt
user: ngoldbaum
date: 2013-02-22 06:25:38
summary: Serif if no longer a keyword argument. Created a setter to control fonts.
Choosing the STIX fonts by defaults, they are the closest match to the cmr10
font used by the matplotlib parser. This e-mail thread explains the gory
details: http://matplotlib.1069221.n5.nabble.com/MPL-uses-character-not-defined-by-cmr10-td22780.html
affected #: 1 file
diff -r 37a370b33f90fe7cdb2810641cd9a00755bb6298 -r 321beb7fd671c2e7bbd79a493633b68a270eb972 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -262,7 +262,7 @@
_frb = None
def __init__(self, data_source, bounds, buff_size=(800,800), antialias=True,
periodic=True, origin='center-window', oblique=False, fontsize=18,
- window_size=10.0, serif=True):
+ window_size=10.0):
if not hasattr(self, "pf"):
self.pf = data_source.pf
ts = self._initialize_dataset(self.pf)
@@ -279,8 +279,8 @@
self.set_window(bounds) # this automatically updates the data and plot
self.origin = origin
self.fontsize = fontsize
- self.serif = serif
- self.font_properties = None
+ self.serif = True
+ self._font_properties = None
if self.data_source.center is not None and oblique == False:
center = [self.data_source.center[i] for i in range(len(self.data_source.center))
if i != self.data_source.axis]
@@ -807,13 +807,9 @@
if self._plot_type is None:
self._plot_type = kwargs.pop("plot_type")
PWViewer.__init__(self, *args, **kwargs)
- if self.serif:
- family='serif'
- else:
- family='sans-serif'
+ fname = matplotlib.get_data_path() + '/fonts/ttf/STIXGeneral.ttf'
self.font_properties = \
- FontProperties(family=family, size=self.fontsize)
-
+ self.set_font({size:self.fontsize, fname:fname})
def _setup_origin(self):
origin = self.origin
@@ -934,10 +930,10 @@
labels = [r'$\rm{'+axis_labels[axis_index][i]+
axes_unit_labels[i] + r'}$' for i in (0,1)]
- if self.font_properties is None:
+ if self._font_properties is None:
fp = FontProperties()
else:
- fp = self.font_properties
+ fp = self._font_properties
self.plots[f].axes.set_xlabel(labels[0],fontproperties=fp)
self.plots[f].axes.set_ylabel(labels[1],fontproperties=fp)
@@ -975,6 +971,24 @@
del self._frb[key]
@invalidate_plot
+ def set_font(self, font_dict=None)
+ """set the font and font properties
+
+ Parameters
+ ----------
+ font_dict : dict
+ A dict of keyword parameters to be passed to matplotlib's font manager.
+ See the matplotlib documentation for more details.
+ http://matplotlib.org/api/font_manager_api.html
+
+
+ """
+ if font_dict is None:
+ font_dict = {}
+ self._font_properties = \
+ FontProperties(**font_dict)
+
+ @invalidate_plot
def set_cmap(self, field, cmap):
"""set the colormap for one of the fields
@@ -1158,8 +1172,6 @@
================================== ============================
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels
- serif : boolean
- Determines whether ticks labels are drawn using a serif or sans-serif font.
field_parameters : dictionary
A dictionary of field parameters than can be accessed by derived fields.
@@ -1177,7 +1189,7 @@
_frb_generator = FixedResolutionBuffer
def __init__(self, pf, axis, fields, center='c', width=None, axes_unit=None,
- origin='center-window', fontsize=18, serif=True, field_parameters=None):
+ origin='center-window', fontsize=18, field_parameters=None):
# this will handle time series data and controllers
ts = self._initialize_dataset(pf)
self.ts = ts
@@ -1188,7 +1200,7 @@
axes_unit = units
if field_parameters is None: field_parameters = {}
slc = pf.h.slice(axis, center[axis], center=center, fields=fields, **field_parameters)
- PWViewerMPL.__init__(self, slc, bounds, origin=origin, fontsize=fontsize, serif=serif)
+ PWViewerMPL.__init__(self, slc, bounds, origin=origin, fontsize=fontsize)
self.set_axes_unit(axes_unit)
class ProjectionPlot(PWViewerMPL):
@@ -1275,8 +1287,6 @@
The maximum level to project to.
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
- serif : boolean
- Determines whether ticks labels are drawn using a serif or sans-serif font.
field_parameters : dictionary
A dictionary of field parameters than can be accessed by derived fields.
@@ -1295,7 +1305,7 @@
def __init__(self, pf, axis, fields, center='c', width=None, axes_unit=None,
weight_field=None, max_level=None, origin='center-window', fontsize=18,
- serif=True, field_parameters=None):
+ field_parameters=None):
ts = self._initialize_dataset(pf)
self.ts = ts
pf = self.pf = ts[0]
@@ -1306,8 +1316,7 @@
if field_parameters is None: field_parameters = {}
proj = pf.h.proj(axis, fields, weight_field=weight_field, max_level=max_level,
center=center, **field_parameters)
- PWViewerMPL.__init__(self, proj, bounds, origin=origin, fontsize=fontsize,
- serif=serif)
+ PWViewerMPL.__init__(self, proj, bounds, origin=origin, fontsize=fontsize)
self.set_axes_unit(axes_unit)
class OffAxisSlicePlot(PWViewerMPL):
@@ -1349,8 +1358,6 @@
set, an arbitrary grid-aligned north-vector is chosen.
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
- serif : boolean
- Determines whether ticks labels are drawn using a serif or sans-serif font.
field_parameters : dictionary
A dictionary of field parameters than can be accessed by derived fields.
"""
@@ -1360,7 +1367,7 @@
def __init__(self, pf, normal, fields, center='c', width=None,
axes_unit=None, north_vector=None, fontsize=18,
- serif=True, field_parameters=None):
+ field_parameters=None):
(bounds, center_rot, units) = GetObliqueWindowParameters(normal,center,width,pf)
if axes_unit is None and units != ('1', '1'):
axes_unit = units
@@ -1369,7 +1376,7 @@
# Hard-coding the origin keyword since the other two options
# aren't well-defined for off-axis data objects
PWViewerMPL.__init__(self, cutting, bounds, origin='center-window', periodic=False,
- oblique=True, fontsize=fontsize, serif=serif)
+ oblique=True, fontsize=fontsize)
self.set_axes_unit(axes_unit)
class OffAxisProjectionDummyDataSource(object):
@@ -1458,8 +1465,6 @@
set, an arbitrary grid-aligned north-vector is chosen.
fontsize : integer
The size of the fonts for the axis, colorbar, and tick labels.
- serif : boolean
- Determines whether ticks labels are drawn using a serif or sans-serif font.
"""
_plot_type = 'OffAxisProjection'
@@ -1468,7 +1473,7 @@
def __init__(self, pf, normal, fields, center='c', width=None,
depth=(1, '1'), axes_unit=None, weight_field=None,
max_level=None, north_vector=None, volume=None, no_ghost=False,
- le=None, re=None, interpolated=False, fontsize=18, serif=True):
+ le=None, re=None, interpolated=False, fontsize=18):
(bounds, center_rot, units) = GetObliqueWindowParameters(normal,center,width,pf,depth=depth)
if axes_unit is None and units != ('1', '1', '1'):
axes_unit = units[:2]
@@ -1480,7 +1485,7 @@
# Hard-coding the origin keyword since the other two options
# aren't well-defined for off-axis data objects
PWViewerMPL.__init__(self, OffAxisProj, bounds, origin='center-window', periodic=False,
- oblique=True, fontsize=fontsize, serif=True)
+ oblique=True, fontsize=fontsize)
self.set_axes_unit(axes_unit)
_metadata_template = """
https://bitbucket.org/yt_analysis/yt/commits/977ede52b058/
changeset: 977ede52b058
branch: yt
user: ngoldbaum
date: 2013-02-22 06:30:12
summary: Adding a caveat to set_font.
affected #: 1 file
diff -r 321beb7fd671c2e7bbd79a493633b68a270eb972 -r 977ede52b05867da90f5e2b0c5edd87c5a9b97ab yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -221,7 +221,6 @@
-width[2][0]/pf[units[2]]/2, width[2][0]/pf[units[2]]/2)
return (bounds, center, units)
-
class PlotWindow(object):
r"""
A ploting mechanism based around the concept of a window into a
@@ -981,6 +980,9 @@
See the matplotlib documentation for more details.
http://matplotlib.org/api/font_manager_api.html
+ Caveats
+ -------
+ Axis labels written in mathtext only obey the `size` keyword.
"""
if font_dict is None:
https://bitbucket.org/yt_analysis/yt/commits/f1d0c42163a5/
changeset: f1d0c42163a5
branch: yt
user: ngoldbaum
date: 2013-02-22 06:31:56
summary: Fixing syntax errors.
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/f31c077828d3/
changeset: f31c077828d3
branch: yt
user: ngoldbaum
date: 2013-02-23 03:13:26
summary: Updating the docstrings for set_font.
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/fec1c06afd06/
changeset: fec1c06afd06
branch: yt
user: ngoldbaum
date: 2013-02-23 22:44:22
summary: Removing the fontsize keyword from plot_window. Removing the fontsize attribte
as well, in favor of _font_properties. All the monkeying with matplotlib fonts
is now contained to PWViewerMPL. I've retained the fontsize keyword for all the
user-facing plotting routines.
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/f292fd654ee6/
changeset: f292fd654ee6
branch: yt
user: ngoldbaum
date: 2013-02-23 22:48:57
summary: Removing a stray serif attribute.
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/249d8d227dad/
changeset: 249d8d227dad
branch: yt
user: ngoldbaum
date: 2013-02-23 22:53:58
summary: Fixing a period I deleted for no reason.
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/c070d328e5b9/
changeset: c070d328e5b9
branch: yt
user: ngoldbaum
date: 2013-02-23 23:35:11
summary: Fixing to_pw(), thanks fido!
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/7598cb8b7438/
changeset: 7598cb8b7438
branch: yt
user: ngoldbaum
date: 2013-02-25 19:46:35
summary: Addressing comments.
affected #: 1 file
Diff not available.
https://bitbucket.org/yt_analysis/yt/commits/fb86a365aa71/
changeset: fb86a365aa71
branch: yt
user: MatthewTurk
date: 2013-02-25 19:54:31
summary: Merged in ngoldbaum/yt (pull request #444)
Making tick labels use a serif font by default, bumping the default font size to 18.
affected #: 1 file
Diff not available.
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list