How control whether text & plot elements can go beyond EDGE of plot?

How control whether text & plot elements can go beyond

    > EDGE of plot? Is it possible to have some plot
    > elements and text be able to go over and others get
    > chopped off?

You can turn the clipping attribute on or off for any artist element.
Artist is base class for all matplotlib elements in the figure
(Figure, Axes, Line2D, Patches, Text...)

http://matplotlib.sf.net/matplotlib.artist.html

You will want to set the "clip_on" attribute for any line (or text or
whatever) element

  t = ax.text(x,y,s)
  t.set_clip_on(False)

  l, = ax.plot([1,2,3])
  l.set_clip_on(False)

Or you can use setp to control the properties of one or more artists

   setp([t,l], clip_on=False)

By default when clpping is on, the artists are clipped to the edges of
the Axes rectangle. You can control the clipping box by passing a
custom bbox to clip_box attribute

  from pylab import figure, show, draw, rand
  from matplotlib.transforms import lbwh_to_bbox
  bbox = lbwh_to_bbox(100,200,50,70)
  fig = figure()
  ax = fig.add_subplot(111)

  line, = ax.plot(rand(100), rand(100))
  line.set_clip_box(bbox)
  show()

Note that the clip box is in figure coordinates (pixels from lower,
left)

JDH

John

Thanks! I tried set_clip_on but it did not work for me.
I made the little script below which shows my point.
"Hello" *still* hangs over the left side.
Is this because the coordinates of the text are on
the edge of the plot? Can clip_on be somehow applied
to text with x = 0 as well?

from pylab import *
plot([1,2,3])
t = text(0, 2.2, "Hello", horizontalalignment = 'center')
t.set_clip_on(True)
show()

···

On Wed, 2006-01-04 at 08:32 -0600, John Hunter wrote:

    > How control whether text & plot elements can go beyond
    > EDGE of plot? Is it possible to have some plot
    > elements and text be able to go over and others get
    > chopped off?

You can turn the clipping attribute on or off for any artist element.
Artist is base class for all matplotlib elements in the figure
(Figure, Axes, Line2D, Patches, Text...)

http://matplotlib.sf.net/matplotlib.artist.html

You will want to set the "clip_on" attribute for any line (or text or
whatever) element

  t = ax.text(x,y,s)
  t.set_clip_on(False)

  l, = ax.plot([1,2,3])
  l.set_clip_on(False)

Or you can use setp to control the properties of one or more artists

   setp([t,l], clip_on=False)

By default when clpping is on, the artists are clipped to the edges of
the Axes rectangle. You can control the clipping box by passing a
custom bbox to clip_box attribute

  from pylab import figure, show, draw, rand
  from matplotlib.transforms import lbwh_to_bbox
  bbox = lbwh_to_bbox(100,200,50,70)
  fig = figure()
  ax = fig.add_subplot(111)

  line, = ax.plot(rand(100), rand(100))
  line.set_clip_box(bbox)
  show()

Note that the clip box is in figure coordinates (pixels from lower,
left)

JDH

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
_______________________________________

Christian Seberino, Ph.D.
SPAWAR Systems Center San Diego
Code 2872
49258 Mills Street, Room 158
San Diego, CA 92152-5385
U.S.A.

Phone: (619) 553-9973
Fax : (619) 553-6521
Email: seberino@...391...
_______________________________________