python - matplotlib text not clipped -


when drawing text in matplotlib text(), , interactively panning image, resulting drawn text not clipped data window. counter how plotting data or drawing text using annotate() works, , doesn't make intuitive sense text() uses data window coordinates.

import matplotlib.pyplot plt  plt.ion() fig = plt.figure() ax = fig.add_subplot(111)  ax.text(0.5, 0.2, 'text') ax.annotate('anno', (0.5, 0.3))  plt.draw() 

interactively pan text out of data window on sides. annotate() drawn 'anno' clipped when reference point crosses data window boundary, while text() drawn 'text' not.

i'm not sure if behavior feature or bug, sure seems latter, text interferes axis labels, etc. using 1.2.1 tkagg backend.

an additional question how clip text going outside data window, not when reference coordinate does.

thanks!

this behavior can controled kwarg clip_on:

import matplotlib.pyplot plt  plt.ion() fig = plt.figure() ax = fig.add_subplot(111)  txt = ax.text(0.5, 0.2, 'text') anno = ax.annotate('anno', (0.5, 0.3)) txt_clip = ax.text(0.5, 0.5, 'text-clip', clip_on=true)  plt.draw() 

axes.text doc. there arguments both , against clipping text data area.

there bug in mpl made txt.set_clip_on(true) not work expected.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -