Hi everybody, 
I have the problem, that I cannot add a color bar to a pcolor plot, which I
generate of some Data files. If I do
fig = plt.figure()

plot1 = fig.add_subplot(231,aspect='equal')
plot1.pcolor(xsr)
plot1.axis([0, 127, 0, 127])
plot1.colorbar()

it just gives me
AttributeError: 'AxesSubplot' object has no attribute 'colorbar'
WARNING: Failure executing file: <test.py>

What am I doing wrong? At the end of this file you find the whole plot-file

Thank you for your help,
Markus



#!usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt

# Open files

file1 = open('../physical/x-ray/193XM_phys.am', 'rb')
file1.seek(-131072,2) 
xm=np.fromfile(file1,dtype='>d')
file1.close()

file2 = open('../physical/x-ray/193XSB_phys.am', 'rb')
file2.seek(-131072,2)
xs=np.fromfile(file2,dtype='>d')
file2.close()

file3 = open('../physical/x-ray/193XT_phys.am', 'rb')
file3.seek(-131072,2)
xt=np.fromfile(file3,dtype='>d')
file3.close()

xsr=np.transpose(np.reshape(xs,(128,128)))
xtr=np.transpose(np.reshape(xt,(128,128)))
xmr=np.transpose(np.reshape(xm,(128,128)))

ind_xmax=np.where(xsr==np.max(xsr))[1][0]
ind_ymax=np.where(xsr==np.max(xsr))[0][0]

profil_xsr=np.zeros(np.minimum(ind_xmax,ind_ymax))
profil_xtr=np.zeros(np.minimum(ind_xmax,ind_ymax))
profil_xmr=np.zeros(np.minimum(ind_xmax,ind_ymax))
anzahl_gridpunkte=np.zeros(np.minimum(ind_xmax,ind_ymax))

for k in range(0,26):
    # Schleife über alle Gitterzellen
    for i in range(128):
        for j in range (128):
            if  (k)**2 < (i-ind_ymax)**2+(j-ind_xmax)**2 <= (k+1)**2:
                profil_xsr[k]=profil_xsr[k]+xsr[i][j]
                profil_xtr[k]=profil_xtr[k]+xtr[i][j]
                profil_xmr[k]=profil_xmr[k]+xmr[i][j]
                anzahl_gridpunkte[k]=anzahl_gridpunkte[k]+1

profil_xsr=profil_xsr/anzahl_gridpunkte
profil_xtr=profil_xtr/anzahl_gridpunkte
profil_xmr=profil_xmr/anzahl_gridpunkte
    
fig = plt.figure()

plot1 = fig.add_subplot(231,aspect='equal')
plot1.pcolor(xsr)
plot1.axis([0, 127, 0, 127])
plot1.colorbar()

plot2 = fig.add_subplot(232,aspect='equal')
plot2.pcolor(10**xtr)
plot2.axis([1, 128, 1, 128])

plot3 = fig.add_subplot(233,aspect='equal')
plot3.pcolor(xmr,vmin=0.0,vmax=0.5)
plot3.axis([1, 128, 1, 128])



plot4 = fig.add_subplot(234)
plot4.plot(profil_xsr)
plot4.axis(ymin=0, ymax=10)


plot5 = fig.add_subplot(235)
plot5.plot(profil_xtr)
plot5.axis(ymin=0, ymax=10)

plot6 = fig.add_subplot(236)
plot6.plot(profil_xmr)
plot6.axis([0, 25,0, 1])

fig.show()



-- 
View this message in context: 
http://www.nabble.com/Colorbar-for-pcolor-plot-tp23631013p23631013.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to