I would like to customize matplotlib image display so that i can type control-c and it will copy the image to the clipboard so then i can copy it to openoffice spreadsheet to organize all of my raw data and image results. Is there any way to do this? Thanks!
+1
A:
If you're using the wx backend, FigureCanvasWxAgg
has a Copy_to_Clipboard
method you can use. You could bind the CTRL+C key event to call this method. For an example, see this sample code.
ars
2010-08-26 00:46:53
but is there any way to have the graph automatically update when you call graph functions like plot(), title() (interactive mode like in ipython?)
josh
2010-08-26 01:02:56
you can clear the figure and redraw, or you can use something like the methods for animation on this page: http://www.scipy.org/Cookbook/Matplotlib/Animations
ars
2010-08-26 01:16:42
arg, wx backend doesn't work for me, plots once doesn't work. stuck with tk backend
josh
2010-08-26 01:44:16
ars
2010-08-26 02:24:34
oh, did you mean the update/animation? try googling "matplotlib tk animation", it seems to bring up a number of references that might help.
ars
2010-08-26 02:25:32
The below i posted is what i wanted, but i still have no clue how to, in general, copy an image to a clipboard so i can paste into openoffice
josh
2010-08-26 02:49:51
+1
A:
import matplotlib
import matplotlib.pyplot as plt
if not globals().has_key('__figure'):
__figure = matplotlib.pyplot.figure
def on_key(event):
print event
if event.key=='c':
#print event.canvas.__dict__#.Copy_to_Clipboard(event=event)
# print event.canvas._tkphoto.__dict__
plt.savefig("/tmp/fig.png")
def my_figure():
fig = __figure()
fig.canvas.mpl_connect('key_press_event',on_key)
return fig
matplotlib.pyplot.figure = my_figure
This works for tk backend, but i have no clue how to copy an image to a clipboard. For text, i can use xclip, but images dont work! And for some reason the wx backend doesnt work too well on ubuntu...
josh
2010-08-26 02:47:59