[Matplotlib-users] Python - Matplotlib - Can't plot - Tkinter crashes

2012-03-03 Thread Anand Ramalingam
I have cross posted this at Stackoverflow.com

I installed `python 2.7.2` from `ActiveState` and then installed `matplotlib` 
from the sources. I getting errors when I tried a simple plotting procedure to 
test it.

The error is similar to the one described here 
(http://code.google.com/p/cing/issues/detail?id=268) but it is for Macintosh. I 
work on a Linux machine and the info about machine is given below:

    % cat /etc/redhat-release 
    CentOS release 4.6 (Final)
    
    % uname -a
    Linux scdbuild04 2.6.9-67.ELsmp #1 SMP Fri Nov 16 12:49:06 EST 2007 x86_64 
x86_64 x86_64 GNU/Linux


The error is produced by:

    % python
    ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
    Python 2.7.2 (default, Jun 24 2011, 11:24:26) 
    [GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
    Type help, copyright, credits or license for more information.
     import matplotlib.pylab as plt
     plt.ion()
     x = [1,2,3]
     plt.plot(x)
    Exception in Tkinter callback
    Traceback (most recent call last):
      File /a/b/python2.7.2/linux26_x86_64/lib/python2.7/lib-tk/Tkinter.py, 
line 1410, in __call__
        return self.func(*args)
      File 
/a/b/python2.7.2/linux26_x86_64/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py,
 line 236, in resize
        self.show()
      File 
/a/b/python2.7.2/linux26_x86_64/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py,
 line 240, in draw
        tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
      File 
/a/b/python2.7.2/linux26_x86_64/lib/python2.7/site-packages/matplotlib/backends/tkagg.py,
 line 19, in blit
        tk.call(PyAggImagePhoto, photoimage, id(aggimage), colormode, 
id(bbox_array))
    TclError
    [matplotlib.lines.Line2D object at 0x2a9da13310]


Can some one help me fix this error?

Thanks
Anand
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Dynamic adjustment of axis position and size in figure

2012-03-03 Thread Jae-Joon Lee
tight_layout only works for instances of Subplots. However, ax2, which
is created by calling twinx, is an instance of Axes, and is not
accounted by the tight_layout command.It may be possible to improve
the situation, I doubt it would be easy as the association between ax1
and ax2 is not very explicit in the current implementation.

One workaround is to use axes_grid1 toolkit (this works with current
git master branch but not sure if it will work with v1.1).

Try to replace

  ax1 = fig.add_subplot(1,1,1)

with

  from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost
  ax1 = SubplotHost(fig, 1, 1, 1)
  fig.add_subplot(ax1)

-JJ


On Thu, Dec 8, 2011 at 5:28 AM, Jérôme jer...@jolimont.fr wrote:
 Wed, 7 Dec 2011 20:29:22 +0100
 Jérôme a écrit:

 Is there a way to automatically resize the axis and nicely center the whole
 set {axes + ticklabels + labels} in the figure ?

 One could use add_axes and play with the coordinates until he gets something
 nice, but it gets complicated to have it automatic as things depends on
 - the number of digits of y-axis ticklabels
 - whether or not a secundary y-axis is added on the right (using twinx)

 Hi again, sorry for multi-posting.

 Apparently, figure.tight_layout() does not take into account the secondary
 y-axis on the right.

 Is this a known limitation ? (I don't see it on the caveats paragraph [1].)

 Or is this the use I make of it that is incorrect ?

 Example :

 --

 import pylab

 fig = pylab.figure()

 data_1 = [0,1,2,3]
 data_2 = [0,5,250,3]

 lines = []

 # Primary axis
 ax1 = fig.add_subplot(1,1,1)
 lines.extend (ax1.plot(data_1, 'b'))

 # Secondary axis
 ax2 = pylab.twinx(ax1)
 lines.extend (ax2.plot(data_2, 'g'))

 labels = ['Data 1', 'Data 2']

 fig.tight_layout()

 pylab.show()


 --

 Thanks.

 [1] http://matplotlib.sourceforge.net/users/tight_layout_guide.html

 --
 Jérôme

 --
 Cloud Services Checklist: Pricing and Packaging Optimization
 This white paper is intended to serve as a reference, checklist and point of
 discussion for anyone considering optimizing the pricing and packaging model
 of a cloud services business. Read Now!
 http://www.accelacomm.com/jaw/sfnl/114/51491232/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users