hist() and semilogy

Hello -

I haven't been able to find any useful documentation about semilogy and exactly how i can implement it into a Histogram. I'm simply trying to create a histogram of a lot of data with a y-axis scaled logarithmically. Specifically I am creating a pixel histogram of a FITS image...for anyone who cares. Here is the code i've used to create the histogram:

#! /usr/bin/env python

import Image
import pyfits
import numpy
import numarray
from pylab import *

#Open each image
Gim = pyfits.open('Gimage.fits')

#Create arrays of the data from each image
Garray = Gim[0].data

onedarray = []

xsize,ysize = Garray.shape

for x in xrange(xsize):
     for y in xrange(ysize):
         if Garray[x,y] >= -0.02:
             if Garray[x,y] <= 0.6:
                 onedarray.append(Garray[x,y])

g_hist = hist(onedarray,bins=100)
axis([-0.05,0.65,1,90000])

xlabel('Pixel Number')
ylabel('How Many of Each Pixel')
savefig('test_histPANDA.png')
show()

thanks!!

-Adrian

Hello Adrian,

I'm not sure I understood well, but if you want a histogram with logarithmic
yscale, you may want to use something like:

import pylab
pylab.subplot(111, yscale='log')
pylab.histogram(some_nice_data)
pylab.show()

regrads Matthias

···

On Monday 14 April 2008 22:28:49 Adrian Price-Whelan wrote:

Hello -

I haven't been able to find any useful documentation about semilogy
and exactly how i can implement it into a Histogram. I'm simply trying
to create a histogram of a lot of data with a y-axis scaled
logarithmically. Specifically I am creating a pixel histogram of a
FITS image...for anyone who cares. Here is the code i've used to
create the histogram:

#! /usr/bin/env python

import Image
import pyfits
import numpy
import numarray
from pylab import *

#Open each image
Gim = pyfits.open('Gimage.fits')

#Create arrays of the data from each image
Garray = Gim[0].data

onedarray = []

xsize,ysize = Garray.shape

for x in xrange(xsize):
     for y in xrange(ysize):
         if Garray[x,y] >= -0.02:
             if Garray[x,y] <= 0.6:
                 onedarray.append(Garray[x,y])

g_hist = hist(onedarray,bins=100)
axis([-0.05,0.65,1,90000])

xlabel('Pixel Number')
ylabel('How Many of Each Pixel')
savefig('test_histPANDA.png')
show()

thanks!!

-Adrian

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java
one _______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users