[yt-svn] commit/yt: ngoldbaum: Adding some new features for the timestamp callback.
Bitbucket
commits-noreply at bitbucket.org
Fri Nov 2 12:51:00 PDT 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/d1f7280c3c79/
changeset: d1f7280c3c79
branch: yt
user: ngoldbaum
date: 2012-11-02 20:35:37
summary: Adding some new features for the timestamp callback.
affected #: 1 file
diff -r f227fad041cad0fe4e0ae8ee3e2661f97ce97d15 -r d1f7280c3c79607e859605e02e5a296c2acfc4b6 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -1168,8 +1168,10 @@
'kev': 1e-12 * 7.6e-8 / 6.03,
'mev': 1e-15 * 7.6e-8 / 6.03,
}
+ _bbox_dict = {'boxstyle': 'square,pad=0.6', 'fc': 'white', 'ec': 'black', 'alpha': 1.0}
- def __init__(self, x, y, units=None, format="{time:.3G} {units}", **kwargs):
+ def __init__(self, x, y, units=None, format="{time:.3G} {units}", normalized = False,
+ bbox_dict = None, **kwargs):
"""
annotate_timestamp(x, y, units=None, format="{time:.3G} {units}", **kwargs)
@@ -1177,32 +1179,47 @@
is given ('s', 'ms', 'ns', etc), it will covert the time to this basis. If
*units* is None, it will attempt to figure out the correct value by which to
scale. The *format* keyword is a template string that will be evaluated and
- displayed on the plot. All other *kwargs* will be passed to the text()
- method on the plot axes. See matplotlib's text() functions for more
- information.
+ displayed on the plot. If *normalized* is true, *x* and *y* are interpreted
+ as normalized plot coordinates (0,0 is lower-left and 1,1 is upper-right)
+ otherwise *x* and *y* are assumed to be in plot coordinates. The *bbox_dict*
+ is an optional dict of arguments for the bbox that frames the timestamp, see
+ matplotlib's text annotation guide for more details. All other *kwargs* will
+ be passed to the text() method on the plot axes. See matplotlib's text()
+ functions for more information.
"""
self.x = x
self.y = y
self.format = format
self.units = units
+ self.normalized = normalized
+ if bbox_dict is not None:
+ self.bbox_dict = bbox_dict
+ else:
+ self.bbox_dict = self._bbox_dict
self.kwargs = {'color': 'w'}
self.kwargs.update(kwargs)
def __call__(self, plot):
if self.units is None:
- t = plot.data.pf.current_time
+ t = plot.data.pf.current_time * plot.data.pf['Time']
scale_keys = ['as', 'fs', 'ps', 'ns', 'us', 'ms', 's']
self.units = 's'
for k in scale_keys:
if t < self._time_conv[k]:
break
self.units = k
- t = plot.data.pf.current_time / self._time_conv[self.units.lower()]
+ t = plot.data.pf.current_time * plot.data.pf['Time']
+ t /= self._time_conv[self.units.lower()]
if self.units == 'us':
self.units = '$\\mu s$'
s = self.format.format(time=t, units=self.units)
plot._axes.hold(True)
- plot._axes.text(self.x, self.y, s, **self.kwargs)
+ if self.normalized:
+ plot._axes.text(self.x, self.y, s, horizontalalignment='center',
+ verticalalignment='center',
+ transform = plot._axes.transAxes, bbox=self.bbox_dict)
+ else:
+ plot._axes.text(self.x, self.y, s, bbox=self.bbox_dict, **self.kwargs)
plot._axes.hold(False)
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