Hi Blake,

the following addition should do what you want:

self.ax = self.fig.add_subplot(1,1,1, autoscale_on=False, xlim=(0, 100), 
ylim=(0, 100))

or by hand after creation of the axes

self.ax.set_autoscale_on(False)
xlim(...)                    # or self.ax.set_xlim(...)
ylim(...)

That is you switch off matplotlibs autoscaling and set proper x/y limits 
initially. With that you can remove all further xlim/ylim calls.

On Tuesday 03 March 2009 11:55:49 Blake Friedman wrote:
> Hi,
>
> I have started to use pyplot to create graphs, saving the images and
> generating an animation from the collection.  Pyplot autoscale the
> axes, which isn't suitable for an animation.  At the moment I reset
> them (for every frame) using the xlim / ylim functions:
>
> import matplotlib.pyplot as plt
>
> ...
>
> def draw(self):
>     self.fig = plt.figure()
>     self.ax = self.fig.add_subplot(1,1,1)
>
>     for e in self.graph.E:
>         x, y = [e.u.x, e.v.x], [e.u.y, e.v.y]
>         plt.plot(x, y, 'b', zorder=2, lw=3)
>
>     for v in self.graph.V:
>         x, y = [v.x, v.x], [v.y, v.y]
>         plt.scatter(x, y, c='g', zorder=1, s=120)
>
>     # XXX: There should be a better way than this?
>     plt.xlim( (0, 100) )
>     plt.ylim( (0, 100) )
>
> Is there a better way to do this?
>
> Thanks,
> Blake


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to