Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 615505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:13:39+00:00 2026-05-13T18:13:39+00:00

In Enthought’s Chaco, the TimeFormatter class is used to format the time string of

  • 0

In Enthought’s Chaco, the TimeFormatter class is used to format the time string of the tick
labels. is there a way to specify the time format (something like time.strftime()).

the source code now hard-codes the format when displaying month and day of the month to the american style (MMDD). I would like to add some flexibility so that the time/date format hints would somehow be passed to the TimeFormatter

I dont know of any nice way to do this (other than changing the source code itself (TimeFormatter._formats dictionary))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:13:40+00:00Added an answer on May 13, 2026 at 6:13 pm

    Honestly, the easiest way is going to be to monkeypatch the TimeFormatter’s _formats dictionary:

    from enthought.chaco.scales.formatters import TimeFormatter
    TimeFormatter._formats['days'] = ('%d/%m', '%d%a',)
    

    If you don’t want to do this, then you need to subclass TimeFormatter. That’s easy. What’s more cumbersome is making all the existing scale systems that the chaco.scales package creates use your new subclass rather than the built-in TimeFormatter. If you look at scales.time_scale.TimeScale, it accepts a ‘formatter’ keyword argument in the constructor. So, at the bottom of time_scale.py, when the MDYScales list is built, you’d have to create your own:

    EuroMDYScales = [TimeScale(day_of_month=range(1,31,3), formatter=MyFormatter()),
                 TimeScale(day_of_month=(1,8,15,22), formatter=MyFormatter()),
                 TimeScale(day_of_month=(1,15), formatter=MyFormatter()),
                 TimeScale(month_of_year=range(1,13), formatter=MyFormatter()),
                 TimeScale(month_of_year=range(1,13,3), formatter=MyFormatter()),
                 TimeScale(month_of_year=(1,7), formatter=MyFormatter()),
                 TimeScale(month_of_year=(1,), formatter=MyFormatter())]
    

    Then, when you create the ScalesTickGenerator, you need to pass in these scales to the ScaleSystem:

    euro_scale_system = CalendarScaleSystem(*(HMSScales + EuroMDYScales))
    tick_gen = ScalesTickGenerator(scale=euro_scale_system)
    

    Then you can create the axis, giving it this tick generator:

    axis = PlotAxis(tick_generator = tick_gen)
    

    HTH, sorry this is about a month lag. I don’t really check StackOverflow very much. If you have other chaco questions, I’d recommend signing up on the chaco-users mailing list…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My web application crashes almost once a week due to not enought memory error.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.