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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:21:49+00:00 2026-05-14T07:21:49+00:00

The following code fails to run on Python 2.5.4: from matplotlib import pylab as

  • 0

The following code fails to run on Python 2.5.4:

from matplotlib import pylab as pl
import numpy as np

data = np.random.rand(6,6)
fig = pl.figure(1)
fig.clf()
ax = fig.add_subplot(1,1,1)
ax.imshow(data, interpolation='nearest', vmin=0.5, vmax=0.99)
pl.colorbar()

pl.show()

The error message is

C:\temp>python z.py
Traceback (most recent call last):
  File "z.py", line 10, in <module>
    pl.colorbar()
  File "C:\Python25\lib\site-packages\matplotlib\pyplot.py", line 1369, in colorbar
    ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
  File "C:\Python25\lib\site-packages\matplotlib\figure.py", line 1046, in colorbar
    cb = cbar.Colorbar(cax, mappable, **kw)
  File "C:\Python25\lib\site-packages\matplotlib\colorbar.py", line 622, in __init__
    mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
AttributeError: 'NoneType' object has no attribute 'autoscale_None'

How can I add colorbar to this code?

Following is the interpreter information:

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
  • 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-14T07:21:49+00:00Added an answer on May 14, 2026 at 7:21 am

    Note: I am using python 2.6.2. The same error was raised with your code and the following modification solved the problem.

    I read the following colorbar example: http://matplotlib.sourceforge.net/examples/pylab_examples/colorbar_tick_labelling_demo.html

    from matplotlib import pylab as pl
    import numpy as np
    
    data = np.random.rand(6,6)
    fig = pl.figure(1)
    fig.clf()
    ax = fig.add_subplot(1,1,1)
    img = ax.imshow(data, interpolation='nearest', vmin=0.5, vmax=0.99)
    fig.colorbar(img)
    
    pl.show()
    

    Not sure why your example didn’t work. I’m not that familiar with matplotlib.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In Ruby 1.9.2 Array#rindex accepts block: http://apidock.com/ruby/Array/rindex May 16, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer It isn't a slot machine simulation, but you may find… May 16, 2026 at 12:08 pm
  • Editorial Team
    Editorial Team added an answer dequeueReusableCellWithIdentifier: only returns a cell if it has been marked… May 16, 2026 at 12:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I run the following code from a python interpreter, and expect the insert statement
I have the following section of Razor code and it fails during runtime with
I have the following code that responds to a button click, changes the view
The following piece of code seems to unreliably execute and after and undeterministic time
I have a Python module, wrapper.py , that wraps a C DLL. The DLL
I've got a python program which runs via crontab and that works perfectly. However,
I am trying to use py2exe to distribute a python application I have written.
I keep getting the following InvalidOperationException : The relationship between the two objects cannot
I’m using Linq to extract values from some XML. Shown below is a simplified
This code is works fine when you type 22 and 56 for example, it

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.