On 2013/06/10 6:16 PM, Sudheer Joseph wrote:
> Thank you Eric and CM,
> I have the below piece of code and added the new definition for minorLocs, 
> but gets the below error. I believe I did not fully understand the concept 
> you mentioned.
>

The concept is "subclassing": writing a class that "inherits" most of 
its behavior from another class, while modifying some aspects.

> minorLocs = mdates.MonthLocator(bymonth=[1,3,5,7,9,11],bymonthday=15)
> minorFmt = mdates.DateFormatter('%b')
>

The problem with your change to the following is that MonthLetter should 
be subclassing DateFormatter, as I had it.  With your change it is 
trying to subclass an instance of DateFormatter, not the class itself.

> class MonthLetter(minorFmt):
>      def __init__(self):
>          DateFormatter.__init__(self, "%b")
>      def __call__(*args):
>          s = DateFormatter.__call__(*args)
>          return s[:1]
> minorFmt = MonthLetter()

In the context of your usage, the one change you do need to make to the 
way I wrote the subclasses is to change my "DateFormatter" to 
"mdates.DateFormatter", since you are importing mdates rather than doing

from matplotlib.dates import DateFormatter

(Or, you can add the above import line to your block of imports.)

Eric

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to