On Wednesday, January 26, 2011, David Perlman <dperl...@wisc.edu> wrote:
> I'm trying to make a simple utility for doing a quick check of some data 
> (electrophysiology recordings from our fMRI scanner lab).  I want it to be 
> foolproof as much as possible, so I was trying to figure out how to write a 
> script that would try to plot to the display, then if that didn't work, to 
> save it to a file instead (preferably as pdf, but I could live with png if 
> that was the only option.)
>
> I've been searching the documentation and code examples for a while, and all 
> I can find seems to suggest that the choice of display vs. file is 
> predetermined at the very beginning by the choice of backend.  I suppose that 
> would mean I'd have to put the whole thing inside a try block, then if that 
> didn't work, start over from scratch with a different backend and build the 
> plot again.  I was hoping to find a way to build the plot, then just try to 
> "show" it or something like that, and if that failed, then save it instead.  
> But so far I have not been able to figure out such a thing.  So I would 
> appreciate any help!  Thanks very much!
>
>

You can always put the show call in a try block and do a savefig if
the show fails.  I don't know where you get the idea that you have to
do one or the other...

Unless you are talking about the issue where the closing of a figure
window would cause you to lose the figure data?  In which case, you
should be fine catching the show and doing the savefigg because the
close event never occurred. However, you might get messy this way with
a blank figure window...

To be "foolproof" I would just always save first and then attempt to
show.  If the show was successful, you can delete the saved figure.

Sorry for the rambling, but those are my thoughts on it.

Ben Root

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to