On Wed, Jan 20, 2010 at 1:13 PM, Kurt Forrester
<kurtforres...@hotmail.com> wrote:
> I am not too sure what the design behaviour is but it is certainly not doing
> what I expected. I do appreciate your effort in resolving this. Please do
> let me know if there are any further tests I can perform to demonstrate the
> issue or test for fixes.
>
"annotate" is meant to annotate a data point. It does not have much
meaning to draw the annotating text when the annotated data point is
not visible (i.e. when the data point is outside the axes). And this
is the default behavior of the current matplotlib.
As I cannot reproduce the problem, it is hard to track down what is wrong.
I'm attaching a little debugging script. Please try to run this code
and report the output. For example, I get
annotation_clip = False
_check_xy returning True
Drawing Text
Your output may be different.
Regards,
-JJ
import matplotlib.pyplot as plt
fig = plt.figure()
ax=plt.subplot(111)
a1 = ax.annotate("Test", (-0.1, 0.5), annotation_clip=False)
from matplotlib.text import Text, Annotation
class AnnotationDebug(Annotation):
def _check_xy(self, renderer, xy_pixel):
b = self.get_annotation_clip()
print "annotation_clip = ", b
if b or (b is None and self.xycoords == "data"):
# check if self.xy is inside the axes.
print "checking is point is inside the axes : ", xy_pixel
contains_point = self.axes.contains_point(xy_pixel)
print "contains_point = ", contains_point
if not contains_point:
print "_check_xy returning False"
return False
print "_check_xy returning True"
return True
def draw(self, renderer):
"""
Draw the :class:`Annotation` object to the given *renderer*.
"""
if renderer is not None:
self._renderer = renderer
if not self.get_visible(): return
xy_pixel = self._get_position_xy(renderer)
if not self._check_xy(renderer, xy_pixel):
print "exit without drawing due to annotation_clip"
return
self._update_position_xytext(renderer, xy_pixel)
self.update_bbox_position_size(renderer)
if self.arrow is not None:
if self.arrow.figure is None and self.figure is not None:
self.arrow.figure = self.figure
self.arrow.draw(renderer)
if self.arrow_patch is not None:
if self.arrow_patch.figure is None and self.figure is not None:
self.arrow_patch.figure = self.figure
self.arrow_patch.draw(renderer)
print "Drawing Text"
Text.draw(self, renderer)
a1.__class__ = AnnotationDebug
plt.show()
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users