SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Damon M. <dam...@gm...> - 2012年07月23日 21:43:23
Hello all,
So, as per Philip's suggestion
(https://github.com/matplotlib/matplotlib/pull/737) I've started
encapsulating fplot functionality into a class. The point of this is so
that the user can call either of the following:
FPlot_instance = ax.fplot(f, [x0, y0, x1, y1])
ax.fplot(FPlot_instance, ...)
Each of these is valid. The first does 'the obvious', as seen in the
closed PR above. The second takes an instance of an FPlot object,
presumably the user would also pass new limits to, say, zoom out. Then
the plot is updated as necessary. This was also Philip's suggestion and
there is a nice working example of changing the limits of a plot to get
a more highly resolved image in examples/event_handling/viewlims.py
I haven't put in a new pull request because I can't decide which of
these methods is better. In short, the viewlims.py example uses a
callback to adjust the plot if the user calls set_xlim or set_ylim.
Would it be sensible to use a callback for fplot buried in the FPlot
class or use my initial thought, which is to pass in a new tuple
describing the new axes limits and update if necessary?
The code isn't complete so I'm reluctant to file a new PR, but if there
is overwhelming desire for people to see the code (perhaps due to my
poor explanation) then I'll open a new PR so everyone can give their two
pence.
Suggestions welcome :)
-- 
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Eric F. <ef...@ha...> - 2012年07月23日 22:20:43
On 2012年07月23日 11:43 AM, Damon McDougall wrote:
> Hello all,
>
> So, as per Philip's suggestion
> (https://github.com/matplotlib/matplotlib/pull/737) I've started
> encapsulating fplot functionality into a class. The point of this is so
> that the user can call either of the following:
>
> FPlot_instance = ax.fplot(f, [x0, y0, x1, y1])
> ax.fplot(FPlot_instance, ...)
The second of these seems odd to me; I would expect FPlot_instance to 
have a __call__ method, so the normal use of an existing instance would be
FPlot_instance(...)
Also, regarding the second argument in the first form: I would think it 
more natural to split it up into a required [x0, x1] and an optional 
[y0, y1], with autoscaling if it is not provided.
Eric
From: Benjamin R. <ben...@ou...> - 2012年07月24日 00:38:14
On Monday, July 23, 2012, Eric Firing wrote:
> On 2012年07月23日 11:43 AM, Damon McDougall wrote:
> > Hello all,
> >
> > So, as per Philip's suggestion
> > (https://github.com/matplotlib/matplotlib/pull/737) I've started
> > encapsulating fplot functionality into a class. The point of this is so
> > that the user can call either of the following:
> >
> > FPlot_instance = ax.fplot(f, [x0, y0, x1, y1])
> > ax.fplot(FPlot_instance, ...)
>
> The second of these seems odd to me; I would expect FPlot_instance to
> have a __call__ method, so the normal use of an existing instance would be
>
> FPlot_instance(...)
>
> Also, regarding the second argument in the first form: I would think it
> more natural to split it up into a required [x0, x1] and an optional
> [y0, y1], with autoscaling if it is not provided.
>
> Eric
Agreed, it is a bit odd/awkward, and I also agree about autoscaling.
With the whole viewlims callbacks, make sure you have the class disconnect
itself upon removal, such as through cla().
l <https://lists.sourceforge.net/lists/listinfo/matplotlib-devel>
Cheers!
Ben Root
From: Damon M. <dam...@gm...> - 2012年07月24日 09:16:34
On Mon, Jul 23, 2012 at 08:38:07PM -0400, Benjamin Root wrote:
> On Monday, July 23, 2012, Eric Firing wrote:
> 
> > On 2012年07月23日 11:43 AM, Damon McDougall wrote:
> > > Hello all,
> > >
> > > So, as per Philip's suggestion
> > > (https://github.com/matplotlib/matplotlib/pull/737) I've started
> > > encapsulating fplot functionality into a class. The point of this is so
> > > that the user can call either of the following:
> > >
> > > FPlot_instance = ax.fplot(f, [x0, y0, x1, y1])
> > > ax.fplot(FPlot_instance, ...)
> >
> > The second of these seems odd to me; I would expect FPlot_instance to
> > have a __call__ method, so the normal use of an existing instance would be
> >
That is awesome! I didn't know the __call__ method existed! That's a
much better way of doing it. I love Python.
> >
> > FPlot_instance(...)
> >
> > Also, regarding the second argument in the first form: I would think it
> > more natural to split it up into a required [x0, x1] and an optional
> > [y0, y1], with autoscaling if it is not provided.
> >
> > Eric
> 
> 
> Agreed, it is a bit odd/awkward, and I also agree about autoscaling.
> 
> With the whole viewlims callbacks, make sure you have the class disconnect
> itself upon removal, such as through cla().
>
So are you suggesting autoscaling over a callback?
> l <https://lists.sourceforge.net/lists/listinfo/matplotlib-devel>
> Cheers!
> Ben Root
-- 
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /