# 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.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!!

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()

···

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.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!!