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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:40:02+00:00 2026-05-26T02:40:02+00:00

So far I have the following code: colors = (‘k’,’r’,’b’) ax = [] for

  • 0

So far I have the following code:

colors = ('k','r','b')
ax = []
for i in range(3):
    ax.append(plt.axes())
    plt.plot(datamatrix[:,0],datamatrix[:,i],colors[i]+'o')
    ax[i].set(autoscale_on=True)

With the autoscale_on=True option for each axis, I thought each plot should have its own y-axis limits, but it appears they all share the same value (even if they share different axes). How do I set them to scale to show the range of each datamatrix[:,i] (just an explicit call to .set_ylim()?) And also, how can I create an offset y-axis for the third variable (datamatrix[:,2]) that might be required above? Thanks all.

  • 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-26T02:40:03+00:00Added an answer on May 26, 2026 at 2:40 am

    It sounds like what you’re wanting is subplots… What you’re doing now doesn’t make much sense (Or I’m very confused by your code snippet, at any rate…).

    Try something more like this:

    import matplotlib.pyplot as plt
    import numpy as np
    
    fig, axes = plt.subplots(nrows=3)
    
    colors = ('k', 'r', 'b')
    for ax, color in zip(axes, colors):
        data = np.random.random(1) * np.random.random(10)
        ax.plot(data, marker='o', linestyle='none', color=color)
    
    plt.show()
    

    enter image description here

    Edit:

    If you don’t want subplots, your code snippet makes a lot more sense.

    You’re trying to add three axes right on top of each other. Matplotlib is recognizing that there’s already a subplot in that exactly size and location on the figure, and so it’s returning the same axes object each time. In other words, if you look at your list ax, you’ll see that they’re all the same object.

    If you really want to do that, you’ll need to reset fig._seen to an empty dict each time you add an axes. You probably don’t really want to do that, however.

    Instead of putting three independent plots over each other, have a look at using twinx instead.

    E.g.

    import matplotlib.pyplot as plt
    import numpy as np
    # To make things reproducible...
    np.random.seed(1977)
    
    fig, ax = plt.subplots()
    
    # Twin the x-axis twice to make independent y-axes.
    axes = [ax, ax.twinx(), ax.twinx()]
    
    # Make some space on the right side for the extra y-axis.
    fig.subplots_adjust(right=0.75)
    
    # Move the last y-axis spine over to the right by 20% of the width of the axes
    axes[-1].spines['right'].set_position(('axes', 1.2))
    
    # To make the border of the right-most axis visible, we need to turn the frame
    # on. This hides the other plots, however, so we need to turn its fill off.
    axes[-1].set_frame_on(True)
    axes[-1].patch.set_visible(False)
    
    # And finally we get to plot things...
    colors = ('Green', 'Red', 'Blue')
    for ax, color in zip(axes, colors):
        data = np.random.random(1) * np.random.random(10)
        ax.plot(data, marker='o', linestyle='none', color=color)
        ax.set_ylabel('%s Thing' % color, color=color)
        ax.tick_params(axis='y', colors=color)
    axes[0].set_xlabel('X-axis')
    
    plt.show()
    

    enter image description here

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

Sidebar

Related Questions

According to what I have found so far, I can use the following code:
So far i have the following code, but it doesn't seem to be working,
MSBuild 3.5 I have the following project structure: trunk/MainSolution.sln trunk/Build/MyBuild.Proj trunk/Library/... trunk/etc... So far,
Basically, I have the following so far: class Foo { public override bool Equals(object
Hello this is may first question and I have found so far the following
So far i have got the code below which works lovely when trying an
So far I have managed to write some code that should print the source
I have the following code on the my page... <a href=javascript:change_product_photo(2);><img id=alternate_product_photo_2 style=border-color:#666666; src=/v/vspfiles/photos/00-6189-2S.jpg
I have the following code: for (i=1; i<=len; i++) { var optcheck = col+'|'+document.getElementById('color').options[i].value;
I have the following code <span style=background-image:url('/product_images/attribute_value_images/78.thumbnail.jpg') class=thumbnail>&nbsp;</span> I need to change the word

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.