[Matplotlib-users] Grid problem?

2012-01-11 Thread David Perlman
When I try to turn on the grid for just one axis, seemingly in perfect 
accordance with the documentation at 
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.grid

it seems like there is a problem.  I am able to make a graph, but trying to 
turn on the grid for just one axis causes an error.

My commands are pasted below.

Am I doing this wrong?  I am doing the best I can to follow the documentation 
exactly.

Thanks for any help!


import matplotlib
matplotlib.use('MacOSX')
import matplotlib.pyplot as plt
fig=plt.figure()
ax=fig.add_subplot(111)
ax.plot([1,2,3])
ax.set_xlabel('Hi there')
ax.grid(True, axis='x')


bombayduck:~$ python
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.use('MacOSX')
>>> import matplotlib.pyplot as plt
>>> fig=plt.figure()
>>> ax=fig.add_subplot(111)
>>> ax.plot([1,2,3])
[]
>>> ax.set_xlabel('Hi there')

>>> ax.grid(True, axis='x')
Traceback (most recent call last):
 File "", line 1, in 
 File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py",
 line 1823, in grid
   self.xaxis.grid(b, **kwargs)
 File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py",
 line 965, in grid
   if len(kwargs): artist.setp(tick.gridline,**kwargs)
 File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py",
 line 1169, in setp
   func = getattr(o,funcName)
AttributeError: 'Line2D' object has no attribute 'set_axis'

-dave--
A neuroscientist is at the video arcade, when someone makes him a $1000 bet
on Pac-Man. He smiles, gets out his screwdriver and takes apart the Pac-Man
game. Everyone says "What are you doing?" The neuroscientist says "Well,
since we all know that Pac-Man is based on electric signals traveling
through these circuits, obviously I can understand it better than the other
guy by going straight to the source!"


--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Grid problem?

2012-01-18 Thread David Perlman
When I try to turn on the grid for just one axis, seemingly in perfect 
accordance with the documentation at 
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.grid

it seems like there is a problem.

My commands are pasted below.

Am I doing this wrong?  I am doing the best I can to follow the documentation 
exactly.

Thanks for any help!


import matplotlib
matplotlib.use('MacOSX')
import matplotlib.pyplot as plt
fig=plt.figure()
ax=fig.add_subplot(111)
ax.plot([1,2,3])
ax.set_xlabel('Hi there')
ax.grid(True, axis='x')


bombayduck:~$ python
Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.use('MacOSX')
>>> import matplotlib.pyplot as plt
>>> fig=plt.figure()
>>> ax=fig.add_subplot(111)
>>> ax.plot([1,2,3])
[]
>>> ax.set_xlabel('Hi there')

>>> ax.grid(True, axis='x')
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py",
 line 1823, in grid
self.xaxis.grid(b, **kwargs)
  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py",
 line 965, in grid
if len(kwargs): artist.setp(tick.gridline,**kwargs)
  File 
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py",
 line 1169, in setp
func = getattr(o,funcName)
AttributeError: 'Line2D' object has no attribute 'set_axis'

-dave--
A neuroscientist is at the video arcade, when someone makes him a $1000 bet
on Pac-Man. He smiles, gets out his screwdriver and takes apart the Pac-Man
game. Everyone says "What are you doing?" The neuroscientist says "Well,
since we all know that Pac-Man is based on electric signals traveling
through these circuits, obviously I can understand it better than the other
guy by going straight to the source!"


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Plot to display or file in the same script?

2011-01-26 Thread David Perlman
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!


--
-dave
"Pseudo-colored pictures of a person's brain lighting up are 
undoubtedly more persuasive than a pattern of squiggles produced by a
polygraph.  That could be a big problem if the goal is to get to the
truth."  -Dr. Steven Hyman, Harvard




--
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


Re: [Matplotlib-users] Plot to display or file in the same script?

2011-01-26 Thread David Perlman
The problem is that if no display is available, the error gets raised on the 
point where I try to create a new figure, long before getting to show(), so I 
can't do anything at all.  Here's what it looks like when I log in without a 
display available:
>>> import matplotlib.pyplot as plt
>>> plt.figure()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Python/Versions/2.6.5/lib/python2.6/site-packages/matplotlib/pyplot.py",
 line 270, in figure
**kwargs)
  File 
"/usr/local/Python/Versions/2.6.5/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py",
 line 83, in new_figure_manager
window = Tk.Tk()
  File "/usr/local/Python/Versions/2.6.5/lib/python2.6/lib-tk/Tkinter.py", line 
1643, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, 
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable


I can do this, which is widely recommended:
>>> import matplotlib
>>> matplotlib.use('Agg')
>>> import matplotlib.pyplot as plt
>>> fig=plt.figure()
>>> fig.save_fig('test.png')

But as far as I can tell from searching, once you do this, there is no way to 
display to the screen.  Unless there is a very clever trick that I don't know 
about...  which I am asking for here...  :-)





On Jan 26, 2011, at 11:16 PM, Benjamin Root wrote:

> On Wednesday, January 26, 2011, David Perlman  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

--
-dave
"Pseudo-colored pictures of a person's brain lighting up are 
undoubtedly more persuasive than a pattern of squiggles produced by a
polygraph.  That could be a big problem if the goal is to get to the
truth."  -Dr. Steven Hyman, Harvard




--
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