[Matplotlib-users] gtkagg backend - update behavior question

2009-11-27 Thread Alastair McKinley
Hi everyone,

I am a new matplotlib user building a simple visualization tool.

I was having some issues with the graph not redrawing and I think I have
reduced it to a minimal case that doesn't work as expected for me.

In the example below one of the data elements is changed on every iteration
of the update function, but the graph does not update as expected.

Am I making a mistake in my usage?

Alastair



#!/usr/bin/env python

import gtk
import gobject
from matplotlib.figure import Figure
import numpy as np

from matplotlib.backends.backend_
gtkagg import FigureCanvasGTKAgg as FigureCanvas

def update(line):
global data
data[20]=data[20]+0.5
line.set_ydata(data)
line.axes.figure.canvas.draw()
return True

win = gtk.Window()
win.connect("destroy", lambda x: x.destroy())
win.set_default_size(400,300)
fig = Figure(figsize=(5,4), dpi=100)
ax = fig.add_subplot(111)
canvas = FigureCanvas(fig)
win.add(canvas)

data = np.random.randn(100)
line, = ax.plot(data)

win.show_all()

gobject.timeout_add(1000,update,line)

gtk.main()
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] axis on top for barh plot

2009-11-27 Thread Mike Anderson
Hi,

How can I put the bottom axis on top (or on top AND on bottom) for a barh plot?

I'm trying to mimic this, made with gnuplot:

  http://www.hep.wisc.edu/cms/comp/cmsprod/dCacheUserUsage.png

within matplotlib, and I've come close,

  http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png


Also, is it possible to just have grid lines in one direction (say, vertical), 
I don't think the horizontal grid is necessary.

Thanks for any help,
Mike



PS: Anyone who is interested, my script for making that is here,
  http://www.hep.wisc.edu/cms/comp/cmsprod/plotDiskUse.py

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] gtkagg backend - update behavior question

2009-11-27 Thread Stephen George
Hi Alastair,

I don't have  clue why yours doesn't work.

however I changed the following line in the update function
data[20]=data[20]+0.5

to
data = np.random.randn(100)

And it started updating the display, with new data each update.
maybe changing a single point is not seen as a big enough change?

Steve

Alastair McKinley wrote:
> Hi everyone,
>
> I am a new matplotlib user building a simple visualization tool.
>
> I was having some issues with the graph not redrawing and I think I 
> have reduced it to a minimal case that doesn't work as expected for me.
>
> In the example below one of the data elements is changed on every 
> iteration of the update function, but the graph does not update as 
> expected.
>
> Am I making a mistake in my usage?
>
> Alastair
>
>
>
> #!/usr/bin/env python
>
> import gtk
> import gobject
> from matplotlib.figure import Figure
> import numpy as np
>
> from matplotlib.backends.backend_
> gtkagg import FigureCanvasGTKAgg as FigureCanvas
>
> def update(line):
> global data
> data[20]=data[20]+0.5
> line.set_ydata(data)
> line.axes.figure.canvas.draw()
> return True
>
> win = gtk.Window()
> win.connect("destroy", lambda x: x.destroy())
> win.set_default_size(400,300)
> fig = Figure(figsize=(5,4), dpi=100)
> ax = fig.add_subplot(111)
> canvas = FigureCanvas(fig)
> win.add(canvas)
>
> data = np.random.randn(100)
> line, = ax.plot(data)
>
> win.show_all()
>
> gobject.timeout_add(1000,update,line)
>
> gtk.main()
> 


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] gtkagg backend - update behavior question

2009-11-27 Thread Jae-Joon Lee
Maybe this thread is helpful.

http://old.nabble.com/Problem-with-simple-use-of-draw%28%29-in-animations-of-arrays-tt26174627.html#a26175190

I guess your code will work simply by calling "recache()" instead of set_ydata.

Regards,

-JJ


On Sat, Nov 28, 2009 at 4:50 AM, Alastair McKinley
 wrote:
> Hi everyone,
>
> I am a new matplotlib user building a simple visualization tool.
>
> I was having some issues with the graph not redrawing and I think I have
> reduced it to a minimal case that doesn't work as expected for me.
>
> In the example below one of the data elements is changed on every iteration
> of the update function, but the graph does not update as expected.
>
> Am I making a mistake in my usage?
>
> Alastair
>
>
>
> #!/usr/bin/env python
>
> import gtk
> import gobject
> from matplotlib.figure import Figure
> import numpy as np
>
> from matplotlib.backends.backend_
> gtkagg import FigureCanvasGTKAgg as FigureCanvas
>
> def update(line):
>     global data
>     data[20]=data[20]+0.5
>     line.set_ydata(data)
>     line.axes.figure.canvas.draw()
>     return True
>
> win = gtk.Window()
> win.connect("destroy", lambda x: x.destroy())
> win.set_default_size(400,300)
> fig = Figure(figsize=(5,4), dpi=100)
> ax = fig.add_subplot(111)
> canvas = FigureCanvas(fig)
> win.add(canvas)
>
> data = np.random.randn(100)
> line, = ax.plot(data)
>
> win.show_all()
>
> gobject.timeout_add(1000,update,line)
>
> gtk.main()
>
> --
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] axis on top for barh plot

2009-11-27 Thread Gökhan Sever
On Fri, Nov 27, 2009 at 5:17 PM, Mike Anderson  wrote:

> Hi,
>
> How can I put the bottom axis on top (or on top AND on bottom) for a barh
> plot?
>
> I'm trying to mimic this, made with gnuplot:
>
>  http://www.hep.wisc.edu/cms/comp/cmsprod/dCacheUserUsage.png
>
> within matplotlib, and I've come close,
>
>  http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png
>
>
> Also, is it possible to just have grid lines in one direction (say,
> vertical), I don't think the horizontal grid is necessary.
>
> Thanks for any help,
> Mike
>

This example might work for your case:

http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline4.html?highlight=subplothost

You can disable lower x-axis ticks and labels by using --assuming you will
try the example in an ipython -pylab

run simple_axisline4.py

ax = gca()

ax.xaxis.set_major_locator(pylab.NullLocator())

However this disable vertical grids as well. Maybe someone else can point
you in the right direction for this.



>
>
>
> PS: Anyone who is interested, my script for making that is here,
>  http://www.hep.wisc.edu/cms/comp/cmsprod/plotDiskUse.py
>
>
> --
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Gökhan
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Large figure sizes get squashed or clipped?

2009-11-27 Thread Michiel de Hoon
I think the best solution to this problem is to have scroll bars in the figure 
window if needed. Depending on the size of the figure (in physical units), the 
size of the window containing the figure, and the zoom factor the scroll bars 
would appear or disappear. This would require some modifications to all GUI 
backends.

The same problem occurs in the Mac OS X backend, where the figure window size 
can be smaller than the requested size if the requested size is larger than the 
monitor size. See bug 2891502:

http://sourceforge.net/tracker/?func=detail&atid=560720&aid=2891502&group_id=80706

Any comments, opinions?


--Michiel.

--- On Wed, 11/25/09, doct...@users.sourceforge.net 
 wrote:

> From: doct...@users.sourceforge.net 
> Subject: Re: [Matplotlib-users] Large figure sizes get squashed or clipped?
> To: "Michael Droettboom" 
> Cc: matplotlib-users@lists.sourceforge.net
> Date: Wednesday, November 25, 2009, 7:43 PM
> Yes, I should have mentioned that;
> saving an image works fine.  But
> then if I want to display it 1:1 with figimage() or such, I
> can't.  :(
>  Silly GUIs, not wanting to display a window larger than my
> screen
> 
> 
> 
> On Wed, Nov 25, 2009 at 9:43 AM, Michael Droettboom 
> wrote:
> > There may be a limitation on window sizes in the
> various GUI backends.  Have
> > you tried using the non-GUI backend (agg), and now
> "show"ing it, but just
> > using "savefig"?
> >
> > Mike
> >
> > doct...@users.sourceforge.net
> wrote:
> >>
> >> I'm trying to make a 10 inch wide by 30 inch high,
> 72 dpi figure and
> >> display it interactively.  Matplotlib seems to
> squash the height for
> >> anything over a certain size, depending on the
> backend:
> >>
> >>
> ---
> >> #!/usr/bin/env python
> >>
> >> import sys, os, matplotlib
> >> matplotlib.use('TkAgg')
> >> import matplotlib.pyplot as plt
> >>
> >> print os.uname()
> >> print sys.version
> >> print matplotlib.__version__
> >> print
> >>
> >> f = plt.figure(figsize=(10,30), dpi=72)
> >> print "figheight before show(): %f" %
> f.get_figheight()
> >> plt.show()
> >> print "figheight after show():  %f" %
> f.get_figheight()
> >>
> --
> >>
> >> Prints this:
> >>
> >> ==
> >> ('Linux', 'prime', '2.6.31-14-generic',
> '#48-Ubuntu SMP Fri Oct 16
> >> 14:05:01 UTC 2009', 'x86_64')
> >> 2.6.4 (r264:75706, Nov  2 2009, 14:44:17)
> >> [GCC 4.4.1]
> >> 0.99.0
> >>
> >> figheight before show(): 30.00
> >> figheight after show():  22.027778
> >> ==
> >>
> >> Tk squashes heights over 12 inches (the heights do
> get larger as you
> >> request larger figures, but not as large as what
> you request); GTK
> >> goes up to 11; and Qt4Agg only goes up to 7.3.
>  WX seems to be the
> >> only backend that will give me a 30 inch figure,
> but even then I have
> >> to manually resize the window to make it fit.
>  This happens in scripts
> >> with pyplot, in ipython with or without -pylab,
> and via the matplotlib
> >> API.
> >>
> >> Is there some limitation on figure sizes?
> >>
> >>
> >>
> --
> >> Let Crystal Reports handle the reporting - Free
> Crystal Reports 2008
> >> 30-Day trial. Simplify your report design,
> integration and deployment - and
> >> focus on what you do best, core application
> coding. Discover what's new with
> >> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> >> ___
> >> Matplotlib-users mailing list
> >> Matplotlib-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>
> >
> > --
> > Michael Droettboom
> > Science Software Branch
> > Operations and Engineering Division
> > Space Telescope Science Institute
> > Operated by AURA for NASA
> >
> >
> 
> --
> Let Crystal Reports handle the reporting - Free Crystal
> Reports 2008 30-Day 
> trial. Simplify your report design, integration and
> deployment - and focus on 
> what you do best, core application coding. Discover what's
> new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 


  

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplot