iw//4, ih//4 ) user_rect = (0,0,ilena.shape[1], ilena.shape[0]) with canv.set_user_coords(device_rect, user_rect): canv.imshow(ilena, 0,0, filter='best' ) #in pixel coordinates col = 20; row = 80 canv.scatter([col], [row], color_rgba=(0.4,0,0.6,0.8), radius=6, markeredgewidth=5 ) #plot p = panels["plot"] device_rect,user_rect = get_panel_rects(p) with canv.set_user_coords(device_rect, user_rect): with canv.get_figure(user_rect) as fig: ax = fig.add_subplot(111) ax.plot( [5,7,10], [5,7,10], 'r-' ) set_foregroundcolor(ax, 'white') set_backgroundcolor(ax, 'black') fig.patch.set_facecolor('none') #inset lena on bottom right hand corner of plot p = panels["plot"] device_rect = ( p["device_x0"]+p["dw"]-iw, p["device_y0"]+p["dh"]-ih, iw, ih ) user_rect = (0,0,ilena.shape[1], ilena.shape[0])
import tempfile from benu.benu import Canvas from benu.utils import set_foregroundcolor, set_backgroundcolor tmp_fname = tempfile.mktemp('.png') canv = Canvas(tmp_fname,500,500) with canv.get_figure(500,500) as fig: ax = fig.add_subplot(111) ax.plot( [5,7,10], [5,7,10], 'r-' ) ax.set_xlabel('Xlabel') ax.set_ylabel('Ylabel') fig.patch.set_facecolor('none') canv.save() print tmp_fname