 # How to use pcolormesh with two masked arrays

I have two arrays and I want to plot the ratio of A/B when A>=B or B/A
when A<B. I can create numpy masked arrays to find the result in
these two instances, but I'm having trouble plotting them. Below I
have a minimal example. I get a plot, but only from the second time I
issue the pcolormesh command. Is there a way to combine the two
arrays for plotting or to plot without overlapping?

Thanks,
Jeremy

import numpy
import matplotlib.pyplot as pyplot

N = 5
A = numpy.array(numpy.random.randint(0, 10, (N,N)), dtype='float64')
B = numpy.array(numpy.random.randint(0, 10, (N,N)), dtype='float64')

Figure = pyplot.figure()
pyplot.pcolormesh(ab)
pyplot.pcolormesh(ba)

Try this:

ratio = numpy.where(A >= B, A/B, B/A)
Figure = pyplot.figure()
pyplot.pcolormesh(ratio)

I hope that helps!

Ben Root

···

On Tue, Feb 1, 2011 at 11:58 AM, Jeremy Conlin <jlconlin@…287…> wrote:

I have two arrays and I want to plot the ratio of A/B when A>=B or B/A

when A<B. I can create numpy masked arrays to find the result in

these two instances, but I’m having trouble plotting them. Below I

have a minimal example. I get a plot, but only from the second time I

issue the pcolormesh command. Is there a way to combine the two

arrays for plotting or to plot without overlapping?

Thanks,

Jeremy