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

  • Home
  • SEARCH
  • 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 6471221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:11:57+00:00 2026-05-25T06:11:57+00:00

I have an array of measurements m, taken every minute. I plot these measurements

  • 0

I have an array of measurements m, taken every minute. I plot these measurements against time by simply saying

import pylab as pl
pl.plot(range(len(m)), m)

this gives me minutes on the x-axis (just because I have measurements in minutes and range(len(m)) gives me integers). How do I quickly change the labeling of the x-axis into hours? I basically need to take the labeling mod 60, but I would like to have only integer hour values.

So in short I want to relabel every multiple of 60 on the x-axis.

  • 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-25T06:11:58+00:00Added an answer on May 25, 2026 at 6:11 am

    Sorry rather than xlabels you need to create an axis and us ax.set_xticklabels:

    from matplotlib.pyplot import figure
    fig = figure()
    ax = fig.add_subplot(111)
    
    
    def mk_labels(vals):
        labels = []
        for i in vals:
            if i % 60 == 0:
                labels.append("Some new special label")
            else:
                labels.append(i)
    
    
     ax.set_xticklabels(mk_labels(range(len(m))))
     ax.plot(range(len(m)), m)
    

    or simply:

     ax.set_xticklabels(["{0}h".format(i) if i % 60 == 0 else i for i in range(len(m))])
    

    Either of these methods will work the first one may be easier if you need more complicated formatting.

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

Sidebar

Related Questions

I have a 4D array of measurements in MATLAB. Each dimension represents a different
I have array of keywords. How can I find if any of these keywords
I have a vector of temperatures and a cell array of Date/Time. I want
I have an array of N measurements that I should present as a graph,
I have the following arrays $meta_boxes[] = array( 'id' => 'measurements', 'title' => 'Measurements',
I have a variable of array containing such as these names ; // Listing
I have array INPUTFILES with n files INPUTFILES=( file_0 ... files_n-1 ) And i
I have array of hashes: @array = [{:id => 1, :status=>R}, {:id => 1,
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>

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.