Beispiel #1
0
import matplotlib.pyplot as plt
ax = plt.subplot(111)
ax.plot([1,2,3], label="test")
l = ax.legend()
d1 = l.draggable()
xy = 1, 2        
txt = ax.annotate("Test", xy, xytext=(-30, 30),
                  textcoords="offset points",
                  bbox=dict(boxstyle="round",fc=(0.2, 1, 1)),
                  arrowprops=dict(arrowstyle="->"))
d2 = txt.draggable()
from matplotlib._png import read_png
from matplotlib.cbook import get_sample_data
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
fn = get_sample_data("lena.png", asfileobj=False)
arr_lena = read_png(fn)
imagebox = OffsetImage(arr_lena, zoom=0.2)
ab = AnnotationBbox(imagebox, xy,
                    xybox=(120., -80.),
                    xycoords='data',
                    boxcoords="offset points",
                    pad=0.5,
                    arrowprops=dict(arrowstyle="->",
                                    connectionstyle="angle,angleA=0,angleB=90,rad=3")
                    )
ax.add_artist(ab)
d3 = ab.draggable(use_blit=True)
plt.show()
                  textcoords="offset points",
                  bbox=dict(boxstyle="round", fc=(0.2, 1, 1)),
                  arrowprops=dict(arrowstyle="->"))
d2 = txt.draggable()

from matplotlib._png import read_png
from matplotlib.cbook import get_sample_data

from matplotlib.offsetbox import OffsetImage, AnnotationBbox

fn = get_sample_data("ada.png", asfileobj=False)
arr_ada = read_png(fn)

imagebox = OffsetImage(arr_ada, zoom=0.2)

ab = AnnotationBbox(imagebox,
                    xy,
                    xybox=(120., -80.),
                    xycoords='data',
                    boxcoords="offset points",
                    pad=0.5,
                    arrowprops=dict(
                        arrowstyle="->",
                        connectionstyle="angle,angleA=0,angleB=90,rad=3"))

ax.add_artist(ab)

d3 = ab.draggable(use_blit=True)

plt.show()
Beispiel #3
0
        ax.yaxis.pan(+1)
    elif event.key == 'down':
        ax.yaxis.pan(-1)
    draw()

fig = figure()
fig.canvas.mpl_connect('key_press_event', onpress)

ax = fig.gca()

ann = AnnotationBbox(OffsetImage(np.arange(256).reshape(16,16)/256.0,
                                 zoom=2,
                                 norm = None,
                                 origin=None),
                     (0.5, 0.5),
                     xybox=(30, 30),
                     xycoords='data',
                     boxcoords="offset points",
                     frameon=True, pad=0.4,  # BboxPatch
                     bboxprops=dict(boxstyle="round", fc="y"),
                     fontsize=None,
                     arrowprops=dict(arrowstyle="->"))

ax.add_artist(ann)

ann.draggable()

show()

#draggable = DraggableAnnotation(a, use_blit=True)
Beispiel #4
0
    draw()


fig = figure()
fig.canvas.mpl_connect('key_press_event', onpress)

ax = fig.gca()

ann = AnnotationBbox(
    OffsetImage(np.arange(256).reshape(16, 16) / 256.0,
                zoom=2,
                norm=None,
                origin=None),
    (0.5, 0.5),
    xybox=(30, 30),
    xycoords='data',
    boxcoords="offset points",
    frameon=True,
    pad=0.4,  # BboxPatch
    bboxprops=dict(boxstyle="round", fc="y"),
    fontsize=None,
    arrowprops=dict(arrowstyle="->"))

ax.add_artist(ann)

ann.draggable()

show()

#draggable = DraggableAnnotation(a, use_blit=True)