I picked "axes_class" because this is what is used in
"subplot_class_factory" function.
I rather prefer "axes_class" because, IMO, subclassing of Axes is not
only for a new projection.
For example, I have a simple subclass of Axes where I have
"baseline"-aligned x-ticklabels (instead of "top" align). Also, from
available options
from matplotlib.projection import AitoffAxes
1) f.add_subplot(1,2,1, projection=AitoffAxes)
2) f.add_subplot(1,2,1, projection_class=AitoffAxes)
3) f.add_subplot(1,2,1, axes_class=AitoffAxes)
I think option 3 makes a slightly more sense.
My patch (which is attached) if for option 3 and simply adds
"axes_class" keyword. It raises an Exception if "projection" is
supplied or polar=True. But feel free to modify or give me
suggestions. If others prefer option 1 or 2, I'll make a subsequent
change for it.
Regards,
-JJ
On Tue, Jul 1, 2008 at 7:51 AM, Michael Droettboom <[EMAIL PROTECTED]> wrote:
> Sounds ok to me. One thing to clarify though -- what to do if both
> "projection" and "axes_class" are provided? Throw an exception?
>
> I have a small problem with the name "axes_class" because it is very
> non-obvious that it corresponds to "projection". Perhaps we should either
> 1) overload projection to take a class as well as strings, or 2) use
> "projection_class" instead of "axes_class". I think I prefer 1) though I'm
> wary of overloading in Python in general.
>
> Cheers,
> Mike
>
> John Hunter wrote:
>>
>> On Mon, Jun 30, 2008 at 2:31 PM, Jae-Joon Lee <[EMAIL PROTECTED]>
>> wrote:
>>
>>
>>>
>>> It seems rather straight forward to implement "axes_class" keyword in
>>> add_subplot() and I may make a patch for it.
>>> So, how does others think?
>>>
>>
>> Seems totally reasonable an we'd be happy to accept a patch.
>>
>> Thanks,
>> JDH
>>
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> Matplotlib-devel mailing list
>> Matplotlib-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
>
Index: figure.py
===================================================================
--- figure.py (revision 5704)
+++ figure.py (working copy)
@@ -716,12 +716,15 @@
fig.add_subplot(111, polar=True) # add a polar subplot
fig.add_subplot(sub) # add Subplot instance sub
- *kwargs* are legal :class:`!matplotlib.axes.Axes` kwargs plus *projection*, which chooses
+ *kwargs* are legal :class:`!matplotlib.axes.Axes` kwargs plus *projection*
+ and *axes_class*. *projection* chooses
a projection type for the axes. (For backward compatibility,
*polar=True* may also be provided, which is equivalent to
*projection='polar'*). Valid values for *projection* are: %s.
Some of these projections support additional *kwargs*, which may
- be provided to :meth:`add_axes`.
+ be provided to :meth:`add_axes`. When *axes_class* is provided (which
+ should be a subclass of :class:`!matplotlib.axes.Axes`), the axes of the
+ subplot will be created with *axes_class*.
The :class:`~matplotlib.axes.Axes` instance will be returned.
@@ -747,17 +750,29 @@
else:
ispolar = kwargs.pop('polar', False)
projection = kwargs.pop('projection', None)
- if ispolar:
- if projection is not None and projection != 'polar':
+ axes_class = kwargs.pop('axes_class', None)
+
+
+ if axes_class:
+ if projection is not None or ispolar:
raise ValueError(
- "polar=True, yet projection='%s'. " +
- "Only one of these arguments should be supplied." %
- projection)
- projection = 'polar'
+ "polar or projection keyword should not be supplied "
+ "when axes_class is used.")
+ a = subplot_class_factory(axes_class)(self, *args, **kwargs)
- projection_class = get_projection_class(projection)
- a = subplot_class_factory(projection_class)(self, *args, **kwargs)
+ else:
+ if ispolar:
+ if projection is not None and projection != 'polar':
+ raise ValueError(
+ "polar=True, yet projection='%s'. " +
+ "Only one of these arguments should be supplied." %
+ projection)
+ projection = 'polar'
+ projection_class = get_projection_class(projection)
+ a = subplot_class_factory(projection_class)(self, *args, **kwargs)
+
+
self.axes.append(a)
self._axstack.push(a)
self.sca(a)
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel