3

I am trying to plot two datasets on a single figure. Essentially this is for tracking fluids in a 2 dimensional porespace.

Both data sets are 250x250 numpy array, the first with data ranging from 0 to 1, the second with data ranging from 2 to 3. The first one is tracking the amount of fluid in a location so 0 would mean 0% fluid and .35 would mean 35% fluid, etc. Similarly the second array would have 2.00 for 0%, 2.35 for 35%, 3.00 for 100%, etc.

Plotting them individually is pretty easy and you get a nice shade effect according to the % of fluid in a location in the array.

What I want to do is plot both images on the same figure with the first data set using Blues (so that 0 is white and 1 is blue and the data in the middle being shaded according to the blue colormap) and then plot the second data set on top of that using Greens (so 2 will be white and 3 will be green, and the data in the middle being shaded according to the green colormap).

2
  • 3
    Where is your question? What have you tried so far? Commented Oct 6, 2012 at 0:42
  • Could you post the images you're trying to overlap? Commented Oct 8, 2012 at 21:01

1 Answer 1

3
from matplotlib import pyplot
import numpy
x = numpy.arange(10)
y = x
z = -x
pyplot.plot(x, y)
pyplot.plot(x, z)  # pyplot.plot(x, y, x, z) works too.

pyplot.show()

You just plot everything before calling show and it'll show up on the same image.

You can also using do the same with imshow, scatter, etc all on the same.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.