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 8583293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:30:00+00:00 2026-06-11T21:30:00+00:00

I am plotting speed/distance data from racing events, using Matplotlib, for example distance vs.

  • 0

I am plotting speed/distance data from racing events, using Matplotlib, for example distance vs. time, with time being horizontal axis and distance being the vertical one.

My inputs are two vectors, one containing the time values in “seconds from event start”, and the other containing “distance travelled so far”. There can be many athletes in the same plot, so I can compare them.

The problem is, if I plot pure time, I get X axis in number of seconds, which is not natural to read:

enter image description here

I can plot the data according to actual date and time of day, and I get readable results, but that is in absolute time, not elapsed time since event start (this one started around 6:00 am):

enter image description here

What I would like would be a way to get elapsed time in HMS format (the same as the second graphic, but with time relative to event start), and possibly with “awareness” of zoom level (switches to hours:minutes, then to days:hours when zoomlevel changes, so as not to clog the labels too close together with scale-irrelevant data).

Thanks for any help!

  • 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-06-11T21:30:01+00:00Added an answer on June 11, 2026 at 9:30 pm

    I suspect that the easiest way is to write your own Formatter (doc) that does the conversion to HMS.

    import matplotlib
    
    class myFormatter(matplotlib.ticker.Formatter):
        def __call__(self,in_value_in_seconds,pos=None):
            hours = int(in_value_in_seconds//(3600))
            in_value_in_seconds -= hours * 3600
            mins = int(in_value_in_seconds//(60))
            in_value_in_seconds -= mins * 60
            secs = int(in_value_in_seconds)
    
            return str(hours) + ":" + str(mins) + ":" + str(secs)
    

    This is (I think) the simplest case and doesn’t support any zooming. It might be better to shove some of this logic into a datetime.deltatime object (or take them as the arguments).

    Combined with MultipleLocator (doc) you can have pretty fine control over where the ticks are.

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

Sidebar

Related Questions

I'm plotting data in Python using matplotlib. I am updating the data of the
I tried simply plotting some data in R with the y-axis label horizontal and
I spend most of my time plotting data, but unfortunately I haven't found a
I am plotting boxplots from this data: MY_LABEL MY_REAL MY_CATEGORY 1 [POS] .56 POS
I am plotting a confusion matrix with matplotlib with the following code: from numpy
When plotting multiple data series using both line specification ( X , Y ,
I am plotting a function of two parameters with matplotlib. I copied an example
when plotting my data using gnuplot, I experience that the right border is cut
I am plotting some curves using twin-axis and also scientific notation. I have set
I am plotting things using matplotlib and Basemap (within a wxpython gui). Currently, my

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.