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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:35:19+00:00 2026-06-06T09:35:19+00:00

I am trying to produce a scatter plot that has two different y-axes and

  • 0

I am trying to produce a scatter plot that has two different y-axes and also a colorbar.

Here is the pseudo-code used:

#!/usr/bin/python

import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax1 = fig.add_subplot(111)
plt.scatter(xgrid,
        ygrid,
        c=be,                   # set colorbar to blaze efficiency
        cmap=cm.hot,
        vmin=0.0,
        vmax=1.0)

cbar = plt.colorbar()
cbar.set_label('Blaze Efficiency')

ax2 = ax1.twinx()
ax2.set_ylabel('Wavelength')

plt.show()

And it produces this plot:
plot

My question is, how do you use a different scale for the "Wavelength" axes, and also, how do you move the colorbar more to right so that it is not in the Wavelength’s way?

  • 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-06T09:35:21+00:00Added an answer on June 6, 2026 at 9:35 am

    @OZ123 Sorry that I took so long to respond. Matplotlib has extensible customizability, sometimes to the point where you get confused to what you are actually doing. Thanks for the help on creating separate axes.

    However, I didn’t think I needed that much control, and I ended up just using the PAD keyword argument in

    fig.colorbar()
    

    and this provided what I needed.

    The pseudo-code then becomes this:

    #!/usr/bin/python
    
    import matplotlib.pyplot as plt
    from matplotlib import cm
    
    fig = plt.figure()
    ax1 = fig.add_subplot(111)
    mappable = ax1.scatter(xgrid,
                           ygrid,
                           c=be,                   # set colorbar to blaze efficiency
                           cmap=cm.hot,
                           vmin=0.0,
                           vmax=1.0)
    
    cbar = fig.colorbar(mappable, pad=0.15)
    cbar.set_label('Blaze Efficiency')
    
    ax2 = ax1.twinx()
    ax2.set_ylabel('Wavelength')
    
    plt.show()
    

    Here is to show what it looks like now:enter image description here:

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

Sidebar

Related Questions

I'm trying to produce assembly code like this (so that it works with nasm)
I'm trying to produce a report that has multiple grouping but does not just
I'm trying to produce a plot with two lines using data taken from stdin.
I am trying to produce a simple scripting system that will be used to
I am trying to produce images without gamma information so that IE8 can display
I am trying to produce a sql query based report that will allow a
I'm trying to produce a clipping area in a UIView that's generated from path
I'm trying to produce a single variable which is a concatenation of two chars
I'm trying to produce an XmlDocument which has a DocType as specified in Apple's
In this code example, i am trying to produce the following view hierarchy Window

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.