I was trying to make a contour plot using numpy.meshgrid and pylab.imshow(); this worked really well at first using some tips I found on stackoverflow (thanks guy! :D )
f = scipy.linspace(1e5,1e6,100)
A = scipy.linspace(1e3,1e5,100)
ff,AA = numpy.meshgrid(f,A)
SLP = calc_SLP2D(ff,AA)
maxAmps = maxA(f)
print maxAmps
brezovich = calc_SLP2D(f,maxAmps)
print brezovich
pylab.imshow(SLP,origin='lower')
pylab.plot(f,maxA(f))
pylab.colorbar()
pylab.xlabel('Frequency [kHz]',{'fontsize':20})
pylab.ylabel('Field Amplitude [A/m]',{'fontsize':20})
pylab.title('Brezovich Criterion',{'fontsize':20})
pylab.grid()
pylab.show()
contour image with incorrect axes http://web.mit.edu/scottnla/Public/SLP_contour.pdf
However, you'll notice that the axes are numbered by the size of the two input matrices and not by the actual values. The abscissa should go from 100,000 to 1,000,000 with the ordinate going from 1000 to 5000. I read on stackoverflow that the solution is to use the 'extent' option as so:
pylab.imshow(SLP,origin='lower',extent=(ff.min(),ff.max(),AA.min(),AA.max()))
This does fix the axes, but scales the image is a really weird way:
And I'm not sure what causes this.
Any thoughts on how I can rescale the axes without making the image look so odd?
thanks!!
nathan lachenmyer