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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:54:13+00:00 2026-05-27T21:54:13+00:00

I want to automatically set the vertical scale on a line graph, based on

  • 0

I want to automatically set the vertical scale on a line graph, based on the maximum value in a dataset. So far I came up with this method:

if 0 < max and max <= 250:
    ymax = 250
elif 250 < max and max <= 500:
    ymax = 500
elif 500 < max and max <= 750:
    ymax = 750
elif 750 < max and max <= 1000:
    ymax = 1000

Could anyone recommend a more concise approach?

  • 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-27T21:54:14+00:00Added an answer on May 27, 2026 at 9:54 pm

    another not so intuitive implementation

    def vScale(xmax):
        return ((xmax-1)/250+1)*250
    

    and here is the result

    [(x,vScale(x)) for x in xrange(0,1200,50)]
    

    [(0, 0), (50, 250), (100, 250), (150, 250), (200, 250), (250, 250), (300, 500), (350, 500), (400, 500), (450, 500), (500, 500), (550, 750), (600, 750), (650, 750), (700, 750), (750, 750), (800, 1000), (850, 1000), (900, 1000), (950, 1000), (1000, 1000), (1050, 1250), (1100, 1250), (1150, 1250)]

    And yet another implementation

    limits=[0,250,500,750,1000]
    ymax=limits[bisect.bisect_right(limits,xmax-1)]
    

    Add one more to the bouquet

    def vScale(xmax):
        return [250,500,750,1000][(xmax-1)/250]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Stackpanel and want that the items automatically set their sizes regarding
I want to set my server to automatically build my application upon commit on
I want to create a custom set that will automatically convert objects into a
How can I set Tomcat to automatically redirect to www? I want that if
I know that the mysql host is automatically set to localhost. I want to
I am new to sql and How can I automatically set the value of
I want to automatically commit the database when we copy files from one branch
I have a CheckedListBox, and I want to automatically tick one of the items
I get poorly formatted invoice-related email from my payment gateway. I want to automatically
I want Eclipse to automatically generate Javadoc comments for my getter and setter methods

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.