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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:47:26+00:00 2026-05-28T05:47:26+00:00

The problem that I am facing at the moment as can be seen in

  • 0

The problem that I am facing at the moment as can be seen in the picture

Is that the Y-axis on the left bottom plot is way to big, ranging from -100 to +600. Is there a way to modify this? I tried a lot but couldn’t find it.

    # the random data
    x = np.random.randint(0,500,100000)
    y = np.random.randn(100000)



    fig = plt.figure(1, figsize=(5.5,5.5))

    from mpl_toolkits.axes_grid1 import make_axes_locatable

    # the scatter plot:
    axScatter = plt.subplot(111)
    axScatter.scatter(x, y)
    axScatter.set_aspect(1.)
    # create new axes on the right and on the top of the current axes
    # The first argument of the new_vertical(new_horizontal) method is
    # the height (width) of the axes to be created in inches.
    divider = make_axes_locatable(axScatter)
    axHistx = divider.append_axes("top", 1.2, pad=0.1, sharex=axScatter)
    axHisty = divider.append_axes("right", 1.2, pad=0.1, sharey=axScatter)

    # make some labels invisible
    plt.setp(axHistx.get_xticklabels() + axHisty.get_yticklabels(),
             visible=False)

    # now determine nice limits by hand:
    binwidth = 0.25
    print np.max(np.fabs(y))
    print np.max(np.fabs(x))

    xymax = np.max( [np.max(np.fabs(x)), np.max(np.fabs(y))] )

    print xymax #will always be gene length wich should not be

    lim = ( int(xymax/binwidth) + 1) * binwidth
    print lim
    bins = np.arange(0, lim + binwidth, binwidth)
    print bins

    #two histo grams, should stay of this?
    axHistx.hist(x, bins=bins)
    axHisty.hist(y, bins=bins, orientation='horizontal')

    # the xaxis of axHistx and yaxis of axHisty are shared with axScatter,
    # thus there is no need to manually adjust the xlim and ylim of these
    # axis.

    #axHistx.axis["bottom"].major_ticklabels.set_visible(False)
    for tl in axHistx.get_xticklabels():
        tl.set_visible(False)
    axHistx.set_yticks([0, 50, 100,200])

    #axHisty.axis["left"].major_ticklabels.set_visible(False)
    for tl in axHisty.get_yticklabels():
        tl.set_visible(False)
    axHisty.set_xticks([0, 50000, 100000])

    plt.draw()
    plt.show()
    plt.savefig('.png')

Now I can use: axScatter.set_ylim(-5, 5)
And shrink the axes but then this happens:
squased

This is a re-post as somehow all the comments where deleted…

  • 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-28T05:47:27+00:00Added an answer on May 28, 2026 at 5:47 am

    Find below an alternative that is a mixture of your code and the code from matplotlib examples.
    I think you can start from this point, calculating limits I have calculated manually:

    enter image description here

    from matplotlib import pyplot as plt
    from mpl_toolkits.axes_grid1 import make_axes_locatable
    import numpy as np
    
    x = np.random.randint(0, 500, 100000)
    y = np.random.randn(100000)
    
    # definitions for the axes
    left, width = 0.1, 0.65
    bottom, height = 0.1, 0.65
    bottom_h = left_h = left + width + 0.02
    
    rect_scatter = [left, bottom, width, height]
    rect_histx = [left, bottom_h, width, 0.2]
    rect_histy = [left_h, bottom, 0.2, height]
    
    fig = plt.figure(1, figsize=(5.5,5.5))
    
    axScatter = plt.axes(rect_scatter)
    axHistx = plt.axes(rect_histx)
    axHisty = plt.axes(rect_histy)
    
    # the scatter plot:
    axScatter.scatter(x, y)
    
    binwidth = 0.25
    xymax = np.max( [np.max(np.fabs(x)), np.max(np.fabs(y))] )
    lim = ( int(xymax/binwidth) + 1) * binwidth
    
    axScatter.set_xlim((0, lim))
    axScatter.set_ylim((-5, 10))       # <-- controls y axis. Values should be calculated.
    
    bins = np.arange(-lim, lim + binwidth, binwidth)
    axHistx.hist(x, bins=bins)
    axHisty.hist(y, bins=bins, orientation='horizontal')
    
    axHistx.set_xlim(axScatter.get_xlim())
    axHisty.set_ylim(axScatter.get_ylim())
    
    #axHistx.axis["bottom"].major_ticklabels.set_visible(False)
    for tl in axHistx.get_xticklabels():
        tl.set_visible(False)
    axHistx.set_yticks([0, 50, 200])
    
    #axHisty.axis["left"].major_ticklabels.set_visible(False)
    for tl in axHisty.get_yticklabels():
        tl.set_visible(False)
    axHisty.set_xticks([0, 10000, 20000])
    
    plt.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing problem adding and deleting DataRows from a DataTable that is meant
I'm facing a problem that seems to have no straighforward solution. I'm using java.util.Map
I am facing the problem that I cannot properly map my foreign key table
I'm working with Eclipse and ClearCase and we're facing the problem that there's no
I'm facing a problem while unit testing my forms. The problem is that data
That was helpful kgiannakakis. I'm facing a problem as below: a = ['zbc','2.3'] for
I am new to Python and Numpy, and I am facing a problem, that
I'm facing with an old problem that it made me confuse very much. So
A very standard example of the problem that I am facing is that of
I am facing quite a strange problem at the moment, I have wordpress and

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.